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,21 +107,6 @@ class _AuthPageState extends State<AuthPage> { | ||||||
|         child: Column( |         child: Column( | ||||||
|           mainAxisAlignment: MainAxisAlignment.spaceEvenly, |           mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||||||
|           children: [ |           children: [ | ||||||
|             Text("copy-code-from-browser".i18n()), |  | ||||||
|             TextFormField( |  | ||||||
|                 decoration: InputDecoration( |  | ||||||
|                     hintText: "123-ABC", |  | ||||||
|                     icon: const Icon(Icons.password), |  | ||||||
|                     labelText: "code-hint".i18n())), |  | ||||||
|             Row( |  | ||||||
|               mainAxisAlignment: MainAxisAlignment.spaceEvenly, |  | ||||||
|               children: [ |  | ||||||
|                 TextButton.icon( |  | ||||||
|                     onPressed: () { |  | ||||||
|                       Navigator.pop(context); |  | ||||||
|                     }, |  | ||||||
|                     icon: const Icon(Icons.arrow_back), |  | ||||||
|                     label: Text("back-button".i18n())), |  | ||||||
|             FutureBuilder<int>( |             FutureBuilder<int>( | ||||||
|               future: oauth.handleFullOauth(), |               future: oauth.handleFullOauth(), | ||||||
|               builder: (context, snapshot) { |               builder: (context, snapshot) { | ||||||
|  | @ -133,7 +116,14 @@ class _AuthPageState extends State<AuthPage> { | ||||||
|                   if (snapshot.data != null) { |                   if (snapshot.data != null) { | ||||||
|                     if (snapshot.data != 200) { |                     if (snapshot.data != 200) { | ||||||
|                       return Row( |                       return Row( | ||||||
|                             children: [Text("error ${snapshot.data}")], |                         mainAxisAlignment: MainAxisAlignment.center, | ||||||
|  |                         children: [ | ||||||
|  |                           const Icon(Icons.error), | ||||||
|  |                           const SizedBox( | ||||||
|  |                             width: 24, | ||||||
|  |                           ), | ||||||
|  |                           Text("error ${snapshot.data}"), | ||||||
|  |                         ], | ||||||
|                       ); |                       ); | ||||||
|                     } |                     } | ||||||
|                   } |                   } | ||||||
|  | @ -146,6 +136,15 @@ class _AuthPageState extends State<AuthPage> { | ||||||
|                 } |                 } | ||||||
|               }, |               }, | ||||||
|             ), |             ), | ||||||
|  |             Row( | ||||||
|  |               mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||||||
|  |               children: [ | ||||||
|  |                 TextButton.icon( | ||||||
|  |                     onPressed: () { | ||||||
|  |                       Navigator.pop(context); | ||||||
|  |                     }, | ||||||
|  |                     icon: const Icon(Icons.arrow_back), | ||||||
|  |                     label: Text("back-button".i18n())), | ||||||
|               ], |               ], | ||||||
|             ) |             ) | ||||||
|           ], |           ], | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue