Basic minimum password requirements, plus field-specific errors (#7811)
* add min password requirement * add field specific errors * move email tld check to after other email checks * add password length check to change password dialog * Update src/view/com/modals/ChangePassword.tsx Co-authored-by: Hailey <me@haileyok.com> * Update src/screens/Signup/StepInfo/index.tsx Co-authored-by: Hailey <me@haileyok.com> * fix lint --------- Co-authored-by: Hailey <me@haileyok.com>
This commit is contained in:
@@ -81,8 +81,7 @@ export function Component() {
|
||||
|
||||
const onChangePassword = async () => {
|
||||
const formattedCode = checkAndFormatResetCode(resetCode)
|
||||
// TODO Better password strength check
|
||||
if (!formattedCode || !newPassword) {
|
||||
if (!formattedCode) {
|
||||
setError(
|
||||
_(
|
||||
msg`You have entered an invalid code. It should look like XXXXX-XXXXX.`,
|
||||
@@ -90,6 +89,16 @@ export function Component() {
|
||||
)
|
||||
return
|
||||
}
|
||||
if (!newPassword) {
|
||||
setError(
|
||||
_(msg`Please enter a password. It must be at least 8 characters long.`),
|
||||
)
|
||||
return
|
||||
}
|
||||
if (newPassword.length < 8) {
|
||||
setError(_(msg`Password must be at least 8 characters long.`))
|
||||
return
|
||||
}
|
||||
|
||||
setError('')
|
||||
setIsProcessing(true)
|
||||
@@ -104,7 +113,9 @@ export function Component() {
|
||||
logger.warn('Failed to set new password', {error: e})
|
||||
if (isNetworkError(e)) {
|
||||
setError(
|
||||
'Unable to contact your service. Please check your Internet connection.',
|
||||
_(
|
||||
msg`Unable to contact your service. Please check your Internet connection.`,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
setError(cleanError(errMsg))
|
||||
|
||||
Reference in New Issue
Block a user