diff --git a/mobile/assets/i18n/en-US.json b/mobile/assets/i18n/en-US.json index ddf5b88e7..c57a404d8 100644 --- a/mobile/assets/i18n/en-US.json +++ b/mobile/assets/i18n/en-US.json @@ -193,6 +193,8 @@ "login_form_save_login": "Stay logged in", "login_form_server_empty": "Enter a server URL.", "login_form_server_error": "Could not connect to server.", + "login_password_changed_success": "Password updated successfully", + "login_password_changed_error": "There was an error updating your password", "monthly_title_text_date_format": "MMMM y", "motion_photos_page_title": "Motion Photos", "notification_permission_dialog_cancel": "Cancel", diff --git a/mobile/lib/modules/login/providers/authentication.provider.dart b/mobile/lib/modules/login/providers/authentication.provider.dart index 57723ed74..33d2c0f3e 100644 --- a/mobile/lib/modules/login/providers/authentication.provider.dart +++ b/mobile/lib/modules/login/providers/authentication.provider.dart @@ -113,7 +113,17 @@ class AuthenticationNotifier extends StateNotifier { Store.delete(StoreKey.accessToken), ]); - state = state.copyWith(isAuthenticated: false); + state = state.copyWith( + deviceId: "", + userId: "", + userEmail: "", + firstName: '', + lastName: '', + profileImagePath: '', + isAdmin: false, + shouldChangePassword: false, + isAuthenticated: false, + ); } catch (e) { log.severe("Error logging out $e"); } diff --git a/mobile/lib/modules/login/ui/change_password_form.dart b/mobile/lib/modules/login/ui/change_password_form.dart index 555dd6c0d..b7db83b3f 100644 --- a/mobile/lib/modules/login/ui/change_password_form.dart +++ b/mobile/lib/modules/login/ui/change_password_form.dart @@ -2,13 +2,14 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/modules/backup/providers/backup.provider.dart'; import 'package:immich_mobile/modules/backup/providers/manual_upload.provider.dart'; import 'package:immich_mobile/modules/login/providers/authentication.provider.dart'; -import 'package:immich_mobile/routing/router.dart'; import 'package:immich_mobile/shared/providers/asset.provider.dart'; import 'package:immich_mobile/shared/providers/websocket.provider.dart'; +import 'package:immich_mobile/shared/ui/immich_toast.dart'; class ChangePasswordForm extends HookConsumerWidget { const ChangePasswordForm({Key? key}) : super(key: key); @@ -84,14 +85,35 @@ class ChangePasswordForm extends HookConsumerWidget { .read(manualUploadProvider.notifier) .cancelBackup(); ref.read(backupProvider.notifier).cancelBackup(); - ref.read(assetProvider.notifier).clearAllAsset(); + await ref + .read(assetProvider.notifier) + .clearAllAsset(); ref.read(websocketProvider.notifier).disconnect(); - AutoRouter.of(context).replace(const LoginRoute()); + AutoRouter.of(context).navigateBack(); + + ImmichToast.show( + context: context, + msg: "login_password_changed_success".tr(), + toastType: ToastType.success, + gravity: ToastGravity.TOP, + ); + } else { + ImmichToast.show( + context: context, + msg: "login_password_changed_error".tr(), + toastType: ToastType.error, + gravity: ToastGravity.TOP, + ); } } }, ), + TextButton.icon( + icon: const Icon(Icons.arrow_back), + onPressed: () => AutoRouter.of(context).navigateBack(), + label: const Text('Back'), + ), ], ), ),