-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: option to email support login error (#880)
- Loading branch information
1 parent
dfa971e
commit c39655f
Showing
1 changed file
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import 'package:freecodecamp/models/main/user_model.dart'; | |
import 'package:freecodecamp/ui/views/auth/privacy_view.dart'; | ||
import 'package:pretty_dio_logger/pretty_dio_logger.dart'; | ||
import 'package:stacked_services/stacked_services.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
class AuthenticationService { | ||
static final AuthenticationService _authenticationService = | ||
|
@@ -130,6 +131,7 @@ class AuthenticationService { | |
|
||
Future<void> login(BuildContext context) async { | ||
late final Credentials creds; | ||
FccUserModel? user; | ||
Response? res; | ||
|
||
showDialog( | ||
|
@@ -182,6 +184,8 @@ class AuthenticationService { | |
extractCookies(res); | ||
await writeTokensToStorage(); | ||
await fetchUser(); | ||
|
||
user = await userModel; | ||
} on DioError catch (e) { | ||
Navigator.pop(context); | ||
if (e.response != null) { | ||
|
@@ -239,10 +243,54 @@ class AuthenticationService { | |
), | ||
); | ||
} | ||
} catch (e, stacktrace) { | ||
Navigator.pop(context); | ||
String supportEmail = Uri.encodeComponent('[email protected]'); | ||
String subject = Uri.encodeComponent('Error logging in to mobile app'); | ||
String body = Uri.encodeComponent( | ||
'Please email the below error to [email protected]\n\n${e.toString()}\n${stacktrace.toString()}'); | ||
showDialog( | ||
context: context, | ||
barrierDismissible: false, | ||
routeSettings: const RouteSettings( | ||
name: 'Login View - Error', | ||
), | ||
builder: (context) => AlertDialog( | ||
backgroundColor: const Color(0xFF2A2A40), | ||
title: const Text('Error'), | ||
content: SelectableText( | ||
'Please email the below error to [email protected]\n\n${e.toString()}\n${stacktrace.toString()}', | ||
), | ||
scrollable: true, | ||
actions: [ | ||
TextButton( | ||
style: TextButton.styleFrom( | ||
backgroundColor: const Color(0xFF0a0a23), | ||
), | ||
onPressed: () async { | ||
logout(); | ||
await launchUrl(Uri.parse( | ||
'mailto:$supportEmail?subject=$subject&body=$body')); | ||
Navigator.pop(context); | ||
}, | ||
child: const Text('Email Error'), | ||
), | ||
TextButton( | ||
style: TextButton.styleFrom( | ||
backgroundColor: const Color(0xFF0a0a23), | ||
), | ||
onPressed: () { | ||
logout(); | ||
Navigator.pop(context); | ||
}, | ||
child: const Text('Close'), | ||
), | ||
], | ||
), | ||
); | ||
rethrow; | ||
} | ||
|
||
final user = await userModel; | ||
|
||
if (user != null && user.acceptedPrivacyTerms == false) { | ||
bool? quincyEmails = await Navigator.push( | ||
context, | ||
|