Skip to content

Commit

Permalink
[auth][mob] Gracefully handle registration error (#4666)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Jan 11, 2025
2 parents 8263eb3 + d8118d1 commit 54f9908
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
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
4 changes: 4 additions & 0 deletions mobile/lib/generated/intl/messages_en.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions mobile/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions mobile/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"@@locale ": "en",
"enterYourEmailAddress": "Enter your email address",
"accountWelcomeBack": "Welcome back!",
"emailAlreadyRegistered": "Email already registered.",
"emailNotRegistered": "Email not registered.",
"email": "Email",
"cancel": "Cancel",
"verify": "Verify",
Expand Down
19 changes: 18 additions & 1 deletion mobile/lib/services/user_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,24 @@ class UserService {
} on DioError 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 54f9908

Please sign in to comment.