1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 08:31:59 +00:00

Fixed admin is forced to change password on mobile app (#287)

* Fixed issues

* Upversion and add changed log
This commit is contained in:
Alex 2022-06-30 13:59:02 -05:00 committed by GitHub
parent 97611fa057
commit 992f792c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 23 deletions

View file

@ -0,0 +1,2 @@
* Fixed admin is forced to change password upon logging in on mobile app
* Fixed change password form validation

View file

@ -19,7 +19,7 @@ platform :ios do
desc "iOS Beta" desc "iOS Beta"
lane :beta do lane :beta do
increment_version_number( increment_version_number(
version_number: "1.14.0" version_number: "1.15.0"
) )
increment_build_number( increment_build_number(
build_number: latest_testflight_build_number + 1, build_number: latest_testflight_build_number + 1,

View file

@ -18,6 +18,7 @@ class ChangePasswordForm extends HookConsumerWidget {
final confirmPasswordController = final confirmPasswordController =
useTextEditingController.fromValue(TextEditingValue.empty); useTextEditingController.fromValue(TextEditingValue.empty);
final authState = ref.watch(authenticationProvider); final authState = ref.watch(authenticationProvider);
final formKey = GlobalKey<FormState>();
return Center( return Center(
child: ConstrainedBox( child: ConstrainedBox(
@ -47,15 +48,24 @@ class ChangePasswordForm extends HookConsumerWidget {
), ),
), ),
), ),
PasswordInput(controller: passwordController), Form(
ConfirmPasswordInput( key: formKey,
originalController: passwordController, child: Column(
confirmController: confirmPasswordController, children: [
), PasswordInput(controller: passwordController),
Align( Padding(
alignment: Alignment.center, padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ChangePasswordButton( child: ConfirmPasswordInput(
passwordController: passwordController), originalController: passwordController,
confirmController: confirmPasswordController,
),
),
ChangePasswordButton(
passwordController: passwordController,
formKey: formKey,
),
],
),
) )
], ],
), ),
@ -119,10 +129,12 @@ class ConfirmPasswordInput extends StatelessWidget {
class ChangePasswordButton extends ConsumerWidget { class ChangePasswordButton extends ConsumerWidget {
final TextEditingController passwordController; final TextEditingController passwordController;
final GlobalKey<FormState> formKey;
const ChangePasswordButton({ const ChangePasswordButton({
Key? key, Key? key,
required this.passwordController, required this.passwordController,
required this.formKey,
}) : super(key: key); }) : super(key: key);
@override @override
@ -136,19 +148,21 @@ class ChangePasswordButton extends ConsumerWidget {
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25),
), ),
onPressed: () async { onPressed: () async {
var isSuccess = await ref if (formKey.currentState!.validate()) {
.watch(authenticationProvider.notifier) var isSuccess = await ref
.changePassword(passwordController.value.text); .watch(authenticationProvider.notifier)
.changePassword(passwordController.value.text);
if (isSuccess) { if (isSuccess) {
bool res = bool res =
await ref.watch(authenticationProvider.notifier).logout(); await ref.watch(authenticationProvider.notifier).logout();
if (res) { if (res) {
ref.watch(backupProvider.notifier).cancelBackup(); ref.watch(backupProvider.notifier).cancelBackup();
ref.watch(assetProvider.notifier).clearAllAsset(); ref.watch(assetProvider.notifier).clearAllAsset();
ref.watch(websocketProvider.notifier).disconnect(); ref.watch(websocketProvider.notifier).disconnect();
AutoRouter.of(context).replace(const LoginRoute()); AutoRouter.of(context).replace(const LoginRoute());
}
} }
} }
}, },

View file

@ -219,7 +219,8 @@ class LoginButton extends ConsumerWidget {
if (isAuthenticated) { if (isAuthenticated) {
// Resume backup (if enable) then navigate // 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()); AutoRouter.of(context).push(const ChangePasswordRoute());
} else { } else {
ref.watch(backupProvider.notifier).resumeBackup(); ref.watch(backupProvider.notifier).resumeBackup();

View file

@ -2,7 +2,7 @@ name: immich_mobile
description: Immich - selfhosted backup media file on mobile phone description: Immich - selfhosted backup media file on mobile phone
publish_to: "none" publish_to: "none"
version: 1.14.0+21 version: 1.15.0+22
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"