Skip to content

armgit / ente

Public Imported from GitHub
0

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

Handle locker restrictions gracefully in email verification and 2fa verification flows

ashilkn7899caf4a68a
diff --git a/mobile/packages/accounts/lib/services/user_service.dart b/mobile/packages/accounts/lib/services/user_service.dart
index 7b287622ec..e7ad5304d1 100644
--- a/mobile/packages/accounts/lib/services/user_service.dart
+++ b/mobile/packages/accounts/lib/services/user_service.dart
@@ -140,7 +140,8 @@ class UserService {
context.strings.emailNotRegistered,
),
);
- } else if (enteErrCode != null && enteErrCode == "LOCKER_REGISTRATION_DISABLED") {
+ } else if (enteErrCode != null &&
+ enteErrCode == "LOCKER_REGISTRATION_DISABLED") {
unawaited(
showErrorDialog(
context,
@@ -523,7 +524,26 @@ class UserService {
} on DioException catch (e) {
_logger.info(e);
await dialog.hide();
- if (e.response != null && e.response!.statusCode == 410) {
+ final dynamic data = e.response?.data;
+ final String? enteErrCode =
+ data is Map<String, dynamic> ? data["code"] as String? : null;
+ if (enteErrCode != null &&
+ enteErrCode == 'LOCKER_REGISTRATION_DISABLED') {
+ await showErrorDialog(
+ context,
+ context.strings.oops,
+ 'Locker is available only to Ente photos paid users. Upgrade to a paid plan from Photos to use Locker',
+ );
+ return;
+ } else if (enteErrCode != null &&
+ enteErrCode == 'LOCKER_ROLLOUT_LIMIT') {
+ await showErrorDialog(
+ context,
+ "We're out of beta seats for now",
+ "This preview access has reached capacity. We'll be opening it to more users soon.",
+ );
+ return;
+ } else if (e.response != null && e.response!.statusCode == 410) {
await showErrorDialog(
context,
context.strings.oops,
@@ -920,7 +940,26 @@ class UserService {
} on DioException catch (e) {
await dialog.hide();
_logger.severe(e);
- if (e.response != null && e.response!.statusCode == 404) {
+ final dynamic data = e.response?.data;
+ final String? enteErrCode =
+ data is Map<String, dynamic> ? data["code"] as String? : null;
+ if (enteErrCode != null &&
+ enteErrCode == 'LOCKER_REGISTRATION_DISABLED') {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ 'Locker is available only to Ente photos paid users. Upgrade to a paid plan from Photos to use Locker',
+ );
+ } else if (enteErrCode != null &&
+ enteErrCode == 'LOCKER_ROLLOUT_LIMIT') {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ "We're out of beta seats for now",
+ "This preview access has reached capacity. We'll be opening it to more users soon.",
+ );
+ } else if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired");
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(