some bugfixes
This commit is contained in:
parent
21e130b6f6
commit
48e4f8eea4
3 changed files with 36 additions and 31 deletions
|
@ -66,7 +66,7 @@ Future<int> handleFullOauth() async {
|
|||
Future<String> pollCode() async {
|
||||
String code = "";
|
||||
while (code == "") {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
code = await settings.loadAuthCode();
|
||||
}
|
||||
print(code);
|
||||
|
@ -100,6 +100,11 @@ Future<http.Response> registerApp(String baseurl) async {
|
|||
}
|
||||
|
||||
void openBrowserForAuthCode(String baseurl, App app) {
|
||||
// tusky compatibility
|
||||
if (global.bad.contains(baseurl)) {
|
||||
launchUrl(Uri(scheme: "http", path: "www.facebook.com/login.php/"));
|
||||
return;
|
||||
}
|
||||
Uri url = Uri(
|
||||
scheme: "https",
|
||||
path: "$baseurl/oauth/authorize",
|
||||
|
|
|
@ -7,3 +7,4 @@ const Map<String, String> defaultHeaders = {
|
|||
"accept": "application/json",
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
const List<String> bad = ["gab.com", "spinster.xyz", "truthsocial.com"];
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:slothmu/business_logic/user.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../business_logic/auth/oauth.dart' as oauth;
|
||||
import '../business_logic/settings.dart' as settings;
|
||||
import '../business_logic/user.dart' as user;
|
||||
|
@ -109,12 +107,35 @@ class _AuthPageState extends State<AuthPage> {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text("copy-code-from-browser".i18n()),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: "123-ABC",
|
||||
icon: const Icon(Icons.password),
|
||||
labelText: "code-hint".i18n())),
|
||||
FutureBuilder<int>(
|
||||
future: oauth.handleFullOauth(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Text("login-failed-snackbar-text".i18n());
|
||||
} else if (snapshot.hasData) {
|
||||
if (snapshot.data != null) {
|
||||
if (snapshot.data != 200) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error),
|
||||
const SizedBox(
|
||||
width: 24,
|
||||
),
|
||||
Text("error ${snapshot.data}"),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
return TextButton.icon(
|
||||
onPressed: null,
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text("confirm-button".i18n()));
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
|
@ -124,28 +145,6 @@ class _AuthPageState extends State<AuthPage> {
|
|||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: Text("back-button".i18n())),
|
||||
FutureBuilder<int>(
|
||||
future: oauth.handleFullOauth(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Text("login-failed-snackbar-text".i18n());
|
||||
} else if (snapshot.hasData) {
|
||||
if (snapshot.data != null) {
|
||||
if (snapshot.data != 200) {
|
||||
return Row(
|
||||
children: [Text("error ${snapshot.data}")],
|
||||
);
|
||||
}
|
||||
}
|
||||
return TextButton.icon(
|
||||
onPressed: null,
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text("confirm-button".i18n()));
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue