mirror of
https://github.com/sasjs/server.git
synced 2026-01-15 09:50:06 +00:00
chore: new password should be different to current password
This commit is contained in:
@@ -33,19 +33,23 @@ const UpdatePasswordModal = (props: Props) => {
|
|||||||
const [errorText, setErrorText] = useState('')
|
const [errorText, setErrorText] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (newPassword.length >= 6) {
|
if (
|
||||||
|
currentPassword.length > 0 &&
|
||||||
|
newPassword.length > 0 &&
|
||||||
|
newPassword === currentPassword
|
||||||
|
) {
|
||||||
|
setErrorText('New password should be different to current password.')
|
||||||
|
setHasError(true)
|
||||||
|
} else if (newPassword.length >= 6) {
|
||||||
setErrorText('')
|
setErrorText('')
|
||||||
setHasError(false)
|
setHasError(false)
|
||||||
}
|
}
|
||||||
}, [newPassword])
|
}, [currentPassword, newPassword])
|
||||||
|
|
||||||
const handleBlur = () => {
|
const handleBlur = () => {
|
||||||
if (newPassword.length < 6) {
|
if (newPassword.length < 6) {
|
||||||
setErrorText('Password length should be at least 6 characters.')
|
setErrorText('Password length should be at least 6 characters.')
|
||||||
setHasError(true)
|
setHasError(true)
|
||||||
} else {
|
|
||||||
setErrorText('')
|
|
||||||
setHasError(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user