Merge pull request #30 from ente-io/handle_expired_otts
This commit is contained in:
commit
acea9df47c
|
@ -2,6 +2,7 @@
|
|||
"hi": [
|
||||
"sign_up",
|
||||
"log_in",
|
||||
"log_in_code_expired",
|
||||
"oops",
|
||||
"start_backup",
|
||||
"auth_session_expired",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"description": "Text on the sign up button used during registration"
|
||||
},
|
||||
"log_in": "log in",
|
||||
"log_in_code_expired" : "your verification code has expired",
|
||||
"ok": "ok",
|
||||
"oops": "oops",
|
||||
"@oops": {
|
||||
|
|
|
@ -177,16 +177,29 @@ class UserService {
|
|||
return page;
|
||||
},
|
||||
),
|
||||
(route) => route.isFirst,
|
||||
(route) => route.isFirst,
|
||||
);
|
||||
} else {
|
||||
showErrorDialog(context, AppLocalizations.of(context).oops,
|
||||
"verification failed, please try again");
|
||||
// should never reach here
|
||||
throw Exception("unexpected response during email verification");
|
||||
}
|
||||
} catch (e) {
|
||||
} on DioError catch (e) {
|
||||
await dialog.hide();
|
||||
if (e.response != null && e.response.statusCode == 410) {
|
||||
await showErrorDialog(context, AppLocalizations.of(context).oops,
|
||||
AppLocalizations.of(context).log_in_code_expired);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
showErrorDialog(context, "incorrect code",
|
||||
"authentication failed, please try again");
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.severe(e);
|
||||
showErrorDialog(context, AppLocalizations.of(context).oops,
|
||||
showErrorDialog(context, AppLocalizations
|
||||
.of(context)
|
||||
.oops,
|
||||
"verification failed, please try again");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ ProgressDialog createProgressDialog(BuildContext context, String message) {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
void showErrorDialog(BuildContext context, String title, String content) {
|
||||
Future<dynamic> showErrorDialog(BuildContext context, String title, String content) {
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: [
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text("ok"),
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
|
@ -39,7 +39,7 @@ void showErrorDialog(BuildContext context, String title, String content) {
|
|||
],
|
||||
);
|
||||
|
||||
showDialog(
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
|
@ -48,8 +48,8 @@ void showErrorDialog(BuildContext context, String title, String content) {
|
|||
);
|
||||
}
|
||||
|
||||
void showGenericErrorDialog(BuildContext context) {
|
||||
showErrorDialog(context, "something went wrong", "please try again.");
|
||||
Future<dynamic> showGenericErrorDialog(BuildContext context) {
|
||||
return showErrorDialog(context, "something went wrong", "please try again.");
|
||||
}
|
||||
|
||||
Future<T> showConfettiDialog<T>({
|
||||
|
|
Loading…
Reference in a new issue