Fixes input dialog for password field (#1934)

Fixes an javascript error in the create user dialog where the "event" from the password field is a simple string, no event.
This commit is contained in:
René Pfeuffer
2022-01-26 10:05:22 +01:00
committed by GitHub
parent 872a7260d1
commit 099c0ad6f6
2 changed files with 10 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Password field in "Create User" dialog and other ((#1934)[https://github.com/scm-manager/scm-manager/pull/1934])

View File

@@ -58,7 +58,13 @@ const PasswordConfirmation: FC<InnerProps> = ({ passwordChanged, passwordValidat
setPasswordConfirmationFailed(password !== newConfirmedPassword);
};
const handlePasswordChange = (newPassword: string) => {
const handlePasswordChange = (event: React.ChangeEvent<HTMLInputElement> | string) => {
let newPassword;
if (typeof event === "string") {
newPassword = event;
} else {
newPassword = event.target.value;
}
setPasswordConfirmationFailed(newPassword !== confirmedPassword);
setPassword(newPassword);
setPasswordValid(validatePassword(newPassword));
@@ -70,7 +76,7 @@ const PasswordConfirmation: FC<InnerProps> = ({ passwordChanged, passwordValidat
<InputField
label={t("password.newPassword")}
type="password"
onChange={event => handlePasswordChange(event.target.value)}
onChange={event => handlePasswordChange(event)}
value={password}
validationError={!passwordValid}
errorMessage={t("password.passwordInvalid")}