Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] Handle registration error

Neeraj Gupta5bd0d3369d8c
diff --git a/auth/lib/l10n/arb/app_en.arb b/auth/lib/l10n/arb/app_en.arb
index b46344f8e8..6b0e95d650 100644
--- a/auth/lib/l10n/arb/app_en.arb
+++ b/auth/lib/l10n/arb/app_en.arb
@@ -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",
diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dart
index 7afb7a4c6e..222f8d5d62 100644
--- a/auth/lib/services/user_service.dart
+++ b/auth/lib/services/user_service.dart
@@ -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,