From 992f792c0adba8dba3ac553aa07498915a64301b Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 30 Jun 2022 13:59:02 -0500 Subject: [PATCH] Fixed admin is forced to change password on mobile app (#287) * Fixed issues * Upversion and add changed log --- .../metadata/android/en-US/changelogs/22.txt | 2 + mobile/ios/fastlane/Fastfile | 2 +- .../login/ui/change_password_form.dart | 54 ++++++++++++------- mobile/lib/modules/login/ui/login_form.dart | 3 +- mobile/pubspec.yaml | 2 +- 5 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 mobile/android/fastlane/metadata/android/en-US/changelogs/22.txt diff --git a/mobile/android/fastlane/metadata/android/en-US/changelogs/22.txt b/mobile/android/fastlane/metadata/android/en-US/changelogs/22.txt new file mode 100644 index 000000000..b3c0f487a --- /dev/null +++ b/mobile/android/fastlane/metadata/android/en-US/changelogs/22.txt @@ -0,0 +1,2 @@ +* Fixed admin is forced to change password upon logging in on mobile app +* Fixed change password form validation \ No newline at end of file diff --git a/mobile/ios/fastlane/Fastfile b/mobile/ios/fastlane/Fastfile index dc1895020..1491cf1a2 100644 --- a/mobile/ios/fastlane/Fastfile +++ b/mobile/ios/fastlane/Fastfile @@ -19,7 +19,7 @@ platform :ios do desc "iOS Beta" lane :beta do increment_version_number( - version_number: "1.14.0" + version_number: "1.15.0" ) increment_build_number( build_number: latest_testflight_build_number + 1, diff --git a/mobile/lib/modules/login/ui/change_password_form.dart b/mobile/lib/modules/login/ui/change_password_form.dart index b71b821e6..4e3632e74 100644 --- a/mobile/lib/modules/login/ui/change_password_form.dart +++ b/mobile/lib/modules/login/ui/change_password_form.dart @@ -18,6 +18,7 @@ class ChangePasswordForm extends HookConsumerWidget { final confirmPasswordController = useTextEditingController.fromValue(TextEditingValue.empty); final authState = ref.watch(authenticationProvider); + final formKey = GlobalKey(); return Center( child: ConstrainedBox( @@ -47,15 +48,24 @@ class ChangePasswordForm extends HookConsumerWidget { ), ), ), - PasswordInput(controller: passwordController), - ConfirmPasswordInput( - originalController: passwordController, - confirmController: confirmPasswordController, - ), - Align( - alignment: Alignment.center, - child: ChangePasswordButton( - passwordController: passwordController), + Form( + key: formKey, + child: Column( + children: [ + PasswordInput(controller: passwordController), + Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: ConfirmPasswordInput( + originalController: passwordController, + confirmController: confirmPasswordController, + ), + ), + ChangePasswordButton( + passwordController: passwordController, + formKey: formKey, + ), + ], + ), ) ], ), @@ -119,10 +129,12 @@ class ConfirmPasswordInput extends StatelessWidget { class ChangePasswordButton extends ConsumerWidget { final TextEditingController passwordController; + final GlobalKey formKey; const ChangePasswordButton({ Key? key, required this.passwordController, + required this.formKey, }) : super(key: key); @override @@ -136,19 +148,21 @@ class ChangePasswordButton extends ConsumerWidget { padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25), ), onPressed: () async { - var isSuccess = await ref - .watch(authenticationProvider.notifier) - .changePassword(passwordController.value.text); + if (formKey.currentState!.validate()) { + var isSuccess = await ref + .watch(authenticationProvider.notifier) + .changePassword(passwordController.value.text); - if (isSuccess) { - bool res = - await ref.watch(authenticationProvider.notifier).logout(); + if (isSuccess) { + bool res = + await ref.watch(authenticationProvider.notifier).logout(); - if (res) { - ref.watch(backupProvider.notifier).cancelBackup(); - ref.watch(assetProvider.notifier).clearAllAsset(); - ref.watch(websocketProvider.notifier).disconnect(); - AutoRouter.of(context).replace(const LoginRoute()); + if (res) { + ref.watch(backupProvider.notifier).cancelBackup(); + ref.watch(assetProvider.notifier).clearAllAsset(); + ref.watch(websocketProvider.notifier).disconnect(); + AutoRouter.of(context).replace(const LoginRoute()); + } } } }, diff --git a/mobile/lib/modules/login/ui/login_form.dart b/mobile/lib/modules/login/ui/login_form.dart index 70728e209..ae65431b3 100644 --- a/mobile/lib/modules/login/ui/login_form.dart +++ b/mobile/lib/modules/login/ui/login_form.dart @@ -219,7 +219,8 @@ class LoginButton extends ConsumerWidget { if (isAuthenticated) { // Resume backup (if enable) then navigate - if (ref.watch(authenticationProvider).shouldChangePassword) { + if (ref.watch(authenticationProvider).shouldChangePassword && + !ref.watch(authenticationProvider).isAdmin) { AutoRouter.of(context).push(const ChangePasswordRoute()); } else { ref.watch(backupProvider.notifier).resumeBackup(); diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 63ee71c09..495aeca29 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -2,7 +2,7 @@ name: immich_mobile description: Immich - selfhosted backup media file on mobile phone publish_to: "none" -version: 1.14.0+21 +version: 1.15.0+22 environment: sdk: ">=2.17.0 <3.0.0"