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 {
|
Future<String> pollCode() async {
|
||||||
String code = "";
|
String code = "";
|
||||||
while (code == "") {
|
while (code == "") {
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
code = await settings.loadAuthCode();
|
code = await settings.loadAuthCode();
|
||||||
}
|
}
|
||||||
print(code);
|
print(code);
|
||||||
|
@ -100,6 +100,11 @@ Future<http.Response> registerApp(String baseurl) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
void openBrowserForAuthCode(String baseurl, App app) {
|
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(
|
Uri url = Uri(
|
||||||
scheme: "https",
|
scheme: "https",
|
||||||
path: "$baseurl/oauth/authorize",
|
path: "$baseurl/oauth/authorize",
|
||||||
|
|
|
@ -7,3 +7,4 @@ const Map<String, String> defaultHeaders = {
|
||||||
"accept": "application/json",
|
"accept": "application/json",
|
||||||
"Content-Type": "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:flutter/material.dart';
|
||||||
import 'package:http/http.dart';
|
|
||||||
import 'package:slothmu/business_logic/user.dart';
|
import 'package:slothmu/business_logic/user.dart';
|
||||||
import 'package:localization/localization.dart';
|
import 'package:localization/localization.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import '../business_logic/auth/oauth.dart' as oauth;
|
import '../business_logic/auth/oauth.dart' as oauth;
|
||||||
import '../business_logic/settings.dart' as settings;
|
import '../business_logic/settings.dart' as settings;
|
||||||
import '../business_logic/user.dart' as user;
|
import '../business_logic/user.dart' as user;
|
||||||
|
@ -109,12 +107,35 @@ class _AuthPageState extends State<AuthPage> {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
Text("copy-code-from-browser".i18n()),
|
FutureBuilder<int>(
|
||||||
TextFormField(
|
future: oauth.handleFullOauth(),
|
||||||
decoration: InputDecoration(
|
builder: (context, snapshot) {
|
||||||
hintText: "123-ABC",
|
if (snapshot.hasError) {
|
||||||
icon: const Icon(Icons.password),
|
return Text("login-failed-snackbar-text".i18n());
|
||||||
labelText: "code-hint".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(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
|
@ -124,28 +145,6 @@ class _AuthPageState extends State<AuthPage> {
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
label: Text("back-button".i18n())),
|
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…
Add table
Add a link
Reference in a new issue