From 1fd805aae7ef1cc504b311dba0f4a57d47eeb2e0 Mon Sep 17 00:00:00 2001 From: TPReal Date: Sat, 8 Feb 2025 18:44:37 +0100 Subject: [PATCH] Fixed an error when creating a user with email but no password. --- resources/js/features/user-edit/UserCreateForm.tsx | 7 +++---- resources/js/features/user-edit/UserEditForm.tsx | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/resources/js/features/user-edit/UserCreateForm.tsx b/resources/js/features/user-edit/UserCreateForm.tsx index 01cb04228..4b98fa47c 100644 --- a/resources/js/features/user-edit/UserCreateForm.tsx +++ b/resources/js/features/user-edit/UserCreateForm.tsx @@ -43,10 +43,9 @@ export const UserCreateForm: VoidComponent = (props) => { ? { email: values.email, hasEmailVerified: values.hasEmailVerified, - hasPassword: values.hasPassword, - ...(values.hasPassword && values.password - ? {password: values.password, passwordExpireAt} - : {password: null, passwordExpireAt}), + ...(values.hasPassword + ? {hasPassword: true, password: values.password, passwordExpireAt} + : {hasPassword: false, password: null, passwordExpireAt: null}), } : { email: null, diff --git a/resources/js/features/user-edit/UserEditForm.tsx b/resources/js/features/user-edit/UserEditForm.tsx index e962cef9b..6588323e8 100644 --- a/resources/js/features/user-edit/UserEditForm.tsx +++ b/resources/js/features/user-edit/UserEditForm.tsx @@ -74,14 +74,13 @@ export const UserEditForm: VoidComponent = (props) => { ? { email: values.email, hasEmailVerified: values.hasEmailVerified, - hasPassword: values.hasPassword, ...(values.hasPassword ? oldUser.hasPassword && !values.password ? // The user has a password already and it is not changed. - {passwordExpireAt} + {hasPassword: true, passwordExpireAt} : // New password or a password change. - {password: values.password, passwordExpireAt} - : {password: null, passwordExpireAt}), + {hasPassword: true, password: values.password, passwordExpireAt} + : {hasPassword: false, password: null, passwordExpireAt: null}), } : { email: null,