diff --git a/lib/business_logic/auth/oauth.dart b/lib/business_logic/auth/oauth.dart index 85ad15b..e13995f 100644 --- a/lib/business_logic/auth/oauth.dart +++ b/lib/business_logic/auth/oauth.dart @@ -38,9 +38,10 @@ Response readAuthcode(Request request) { String code = params["code"].toString(); settings.saveAuthCode(code); } - return Response(200, + return Response(308, + headers: {"Content-Type": "text/html; charset=UTF-8"}, body: - ""); + ""); } // returns status code @@ -54,7 +55,6 @@ Future handleFullOauth() async { await settings.saveAuthCode(""); var handler = const Pipeline().addHandler(readAuthcode); var server = await shelf_io.serve(handler, 'localhost', 1312); - server.idleTimeout = const Duration(minutes: 5); await pollCode(); server.close(); return 200; @@ -66,10 +66,9 @@ Future handleFullOauth() async { Future pollCode() async { String code = ""; while (code == "") { - await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 3)); code = await settings.loadAuthCode(); } - print(code); return code; } @@ -77,7 +76,6 @@ Future doOauthFlow() async { String url = await settings.loadInstanceUrl(); try { http.Response response = await registerApp(url); - print(response.body); openBrowserForAuthCode(url, App.fromJson(jsonDecode(response.body))); return response; } catch (e) { diff --git a/lib/business_logic/settings.dart b/lib/business_logic/settings.dart index 60f5540..759d177 100644 --- a/lib/business_logic/settings.dart +++ b/lib/business_logic/settings.dart @@ -1,15 +1,10 @@ import 'package:shared_preferences/shared_preferences.dart'; -import 'package:slothmu/business_logic/auth/oauth.dart'; enum Settings { instanceUrl, username, } -void saveSetting(Settings setting, dynamic value) async { - final prefs = await SharedPreferences.getInstance(); -} - Future saveInstanceUrl(String url) async { final prefs = await SharedPreferences.getInstance(); return await prefs.setString("instance-url", url); diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 2721f65..3158113 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -62,6 +62,7 @@ class _LoginFormState extends State { if (value!.isEmpty || !isValidUsername(name: value)) { return "user-id-not-valid".i18n(); } + return null; }, ), TextButton.icon( @@ -128,9 +129,11 @@ class _AuthPageState extends State { } } return TextButton.icon( - onPressed: null, - icon: const Icon(Icons.check), - label: Text("confirm-button".i18n())); + onPressed: () { + Navigator.pushReplacementNamed(context, "/"); + }, + icon: const Icon(Icons.arrow_forward), + label: Text("confirm".i18n())); } else { return const CircularProgressIndicator(); }