Skip to content

Commit

Permalink
Fixed an error when creating a user with email but no password.
Browse files Browse the repository at this point in the history
  • Loading branch information
TPReal committed Feb 8, 2025
1 parent f58eb7b commit 1fd805a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions resources/js/features/user-edit/UserCreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export const UserCreateForm: VoidComponent<Props> = (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,
Expand Down
7 changes: 3 additions & 4 deletions resources/js/features/user-edit/UserEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ export const UserEditForm: VoidComponent<Props> = (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,
Expand Down

0 comments on commit 1fd805a

Please sign in to comment.