Skip to content

Commit

Permalink
[auth] Handle registration error
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Jan 11, 2025
1 parent 8263eb3 commit 5bd0d33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions auth/lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"useRecoveryKey": "Use recovery key",
"incorrectPasswordTitle": "Incorrect password",
"welcomeBack": "Welcome back!",
"emailAlreadyRegistered": "Email already registered.",
"emailNotRegistered": "Email not registered.",
"madeWithLoveAtPrefix": "made with ❤️ at ",
"supportDevs": "Subscribe to <bold-green>ente</bold-green> to support us",
"supportDiscount": "Use coupon code \"AUTH\" to get 10% off first year",
Expand Down
19 changes: 18 additions & 1 deletion auth/lib/services/user_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,24 @@ class UserService {
} on DioException catch (e) {
await dialog.hide();
_logger.info(e);
if (e.response != null && e.response!.statusCode == 403) {
final String? enteErrCode = e.response?.data["code"];
if (enteErrCode != null && enteErrCode == "USER_ALREADY_REGISTERED") {
unawaited(
showErrorDialog(
context,
context.l10n.oops,
context.l10n.emailAlreadyRegistered,
),
);
} else if (enteErrCode != null && enteErrCode == "USER_NOT_REGISTERED") {
unawaited(
showErrorDialog(
context,
context.l10n.oops,
context.l10n.emailNotRegistered,
),
);
} else if (e.response != null && e.response!.statusCode == 403) {
unawaited(
showErrorDialog(
context,
Expand Down

0 comments on commit 5bd0d33

Please sign in to comment.