diff --git a/frontend/public/locales/en/translations.json b/frontend/public/locales/en/translations.json index 776810383..dc2a1cfd3 100644 --- a/frontend/public/locales/en/translations.json +++ b/frontend/public/locales/en/translations.json @@ -240,6 +240,7 @@ "validate-special-char": "at least 1 special character", "validate-repeated-char": "at most 2 repeated, consecutive characters", "validate-is-email": "The password cannot be an email address.", + "validate-is-url": "The password cannot be a URL.", "validate-is-breached": "The new password is in a list of passwords commonly used on other websites. Please try again with a stronger password." }, "token": { diff --git a/frontend/public/locales/es/translations.json b/frontend/public/locales/es/translations.json index 8891efcbe..8842d6a10 100644 --- a/frontend/public/locales/es/translations.json +++ b/frontend/public/locales/es/translations.json @@ -237,7 +237,8 @@ "validate-special-char": "al menos 1 carácter especial", "validate-repeated-char": "como máximo 2 caracteres repetidos y consecutivos", "validate-is-email": "La contraseña no puede ser una dirección de correo electrónico.", - "validate-breached": "La nueva contraseña se encuentra en una lista de contraseñas comúnmente utilizadas en otros sitios web. Vuelva a intentarlo con una contraseña más segura." + "validate-is-url": "La contraseña no puede ser una URL.", + "validate-is-breached": "La nueva contraseña se encuentra en una lista de contraseñas comúnmente utilizadas en otros sitios web. Vuelva a intentarlo con una contraseña más segura." }, "token": { "service-tokens": "Tokens de servicio", diff --git a/frontend/public/locales/fr/translations.json b/frontend/public/locales/fr/translations.json index a8638dc3b..a65129392 100644 --- a/frontend/public/locales/fr/translations.json +++ b/frontend/public/locales/fr/translations.json @@ -224,6 +224,7 @@ "validate-special-char": "au moins 1 caractère spécial", "validate-repeated-char": "au plus 2 caractères répétés et consécutifs", "validate-is-email": "Le mot de passe ne peut pas être une adresse e-mail.", + "validate-is-url": "Le mot de passe ne peut pas être une URL.", "validate-is-breached": "Le nouveau mot de passe se trouve dans une liste de mots de passe couramment utilisés sur d'autres sites Web. Veuillez réessayer avec un mot de passe plus fort." }, "token": { diff --git a/frontend/public/locales/ko/translations.json b/frontend/public/locales/ko/translations.json index 8f21f6349..e5f6deee7 100644 --- a/frontend/public/locales/ko/translations.json +++ b/frontend/public/locales/ko/translations.json @@ -191,7 +191,8 @@ "validate-special-char": "특수 문자 1개 이상", "validate-repeated-char": "최대 2개의 반복된 연속 문자", "validate-is-email": "비밀번호는 이메일 주소가 될 수 없습니다.", - "validate-breached": "새 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요." + "validate-is-url": "비밀번호는 URL일 수 없습니다.", + "validate-is-breached": "새 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요." }, "token": { "add-dialog": { diff --git a/frontend/public/locales/pt-BR/translations.json b/frontend/public/locales/pt-BR/translations.json index 238cee3fa..362ec2aae 100644 --- a/frontend/public/locales/pt-BR/translations.json +++ b/frontend/public/locales/pt-BR/translations.json @@ -219,7 +219,8 @@ "validate-special-char": "pelo menos 1 caractere especial", "validate-repeated-char": "no máximo 2 caracteres repetidos e consecutivos", "validate-is-email": "A senha não pode ser um endereço de e-mail.", - "validate-breached": "A nova senha está em uma lista de senhas comumente usadas em outros sites. Tente novamente com uma senha mais forte." + "validate-is-url": "A senha não pode ser um URL.", + "validate-is-breached": "A nova senha está em uma lista de senhas comumente usadas em outros sites. Tente novamente com uma senha mais forte." }, "token": { "service-tokens": "Tokens de Serviço", diff --git a/frontend/public/locales/tr/translations.json b/frontend/public/locales/tr/translations.json index 32c3d4635..c1b72d7e3 100644 --- a/frontend/public/locales/tr/translations.json +++ b/frontend/public/locales/tr/translations.json @@ -237,7 +237,8 @@ "validate-special-char": "en az 1 özel karakter", "validate-repeated-char": "en fazla 2 tekrarlanan, ardışık karakter", "validate-is-email": "Şifre bir e-posta adresi olamaz.", - "validate-breached": "Yeni şifre, diğer web sitelerinde yaygın olarak kullanılan şifrelerin listesinde yer almaktadır. Lütfen daha güçlü bir şifre ile tekrar deneyiniz." + "validate-is-url": "Şifre bir URL olamaz.", + "validate-is-breached": "Yeni şifre, diğer web sitelerinde yaygın olarak kullanılan şifrelerin listesinde yer almaktadır. Lütfen daha güçlü bir şifre ile tekrar deneyiniz." }, "token": { "service-tokens": "Servis Belirteçleri", diff --git a/frontend/src/components/signup/UserInfoStep.tsx b/frontend/src/components/signup/UserInfoStep.tsx index 907ce4c57..0c24b2aac 100644 --- a/frontend/src/components/signup/UserInfoStep.tsx +++ b/frontend/src/components/signup/UserInfoStep.tsx @@ -46,6 +46,7 @@ type Errors = { specialChar?: string; repeatedChar?: string; isEmail?: string; + isUrl?: string; isBeachedPassword?: string; }; diff --git a/frontend/src/components/utilities/checks/PasswordCheck.ts b/frontend/src/components/utilities/checks/PasswordCheck.ts index 7ab633c05..7e212873b 100644 --- a/frontend/src/components/utilities/checks/PasswordCheck.ts +++ b/frontend/src/components/utilities/checks/PasswordCheck.ts @@ -1,4 +1,4 @@ -import isEmail from "validator/lib/isEmail"; +import {string} from "yup"; import { checkIsPasswordBreached } from "./checkIsPasswordBreached"; /* eslint-disable no-param-reassign */ @@ -13,6 +13,7 @@ interface PasswordCheckProps { setPasswordErrorSpecialChar: (value: boolean) => void; setPasswordErrorRepeatedChar: (value: boolean) => void; setPasswordErrorIsEmail: (value: boolean) => void; + setPasswordErrorIsUrl: (value: boolean) => void; setPasswordErrorIsBreachedPassword: (value: boolean) => void; } @@ -29,6 +30,7 @@ const passwordCheck = async ({ setPasswordErrorSpecialChar, setPasswordErrorRepeatedChar, setPasswordErrorIsEmail, + setPasswordErrorIsUrl, setPasswordErrorIsBreachedPassword, errorCheck }: PasswordCheckProps) => { @@ -97,13 +99,25 @@ const passwordCheck = async ({ } // isEmail - if (isEmail(password)) { + const emailSchema = string().email(); + + if (await emailSchema.isValid(password)) { setPasswordErrorIsEmail(true); errorCheck = true; } else { setPasswordErrorIsEmail(false); } + // isUrl + const urlSchema = string().url(); + + if (await urlSchema.isValid(password)) { + setPasswordErrorIsUrl(true); + errorCheck = true; + } else { + setPasswordErrorIsUrl(false); + } + // breachedPassword if (await checkIsPasswordBreached(password)) { setPasswordErrorIsBreachedPassword(true); diff --git a/frontend/src/components/utilities/checks/checkPassword.ts b/frontend/src/components/utilities/checks/checkPassword.ts index b44c47df4..5608395a1 100644 --- a/frontend/src/components/utilities/checks/checkPassword.ts +++ b/frontend/src/components/utilities/checks/checkPassword.ts @@ -1,4 +1,4 @@ -import isEmail from "validator/lib/isEmail"; +import {string} from "yup" import { checkIsPasswordBreached } from "./checkIsPasswordBreached"; type Errors = { @@ -10,6 +10,7 @@ type Errors = { specialChar?: string; repeatedChar?: string; isEmail?: string; + isUrl?: string; isBreachedPassword?: string; }; @@ -93,10 +94,19 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom } // isEmail - if (isEmail(password)) { + const emailSchema = string().email(); + + if (await emailSchema.isValid(password)) { errors.isEmail = "The password cannot be an email address"; } + // isUrl + const urlSchema = string().url(); + + if (await urlSchema.isValid(password)) { + errors.isUrl = "The password cannot be a URL"; + } + // breachedPassword if (await checkIsPasswordBreached(password)) { errors.isBreachedPassword = diff --git a/frontend/src/pages/password-reset.tsx b/frontend/src/pages/password-reset.tsx index c1ba52605..85875c338 100644 --- a/frontend/src/pages/password-reset.tsx +++ b/frontend/src/pages/password-reset.tsx @@ -36,6 +36,7 @@ export default function PasswordReset() { const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = useState(false); const [passwordErrorRepeatedChar, setPasswordErrorRepeatedChar] = useState(false); const [passwordErrorIsEmail, setPasswordErrorIsEmail] = useState(false); + const [passwordErrorIsUrl, setPasswordErrorIsUrl] = useState(false); const [passwordErrorIsBreachedPassword, setPasswordErrorIsBreachedPassword] = useState(false); const router = useRouter(); @@ -81,6 +82,7 @@ export default function PasswordReset() { setPasswordErrorSpecialChar, setPasswordErrorRepeatedChar, setPasswordErrorIsEmail, + setPasswordErrorIsUrl, setPasswordErrorIsBreachedPassword, errorCheck: false }); @@ -243,6 +245,7 @@ export default function PasswordReset() { setPasswordErrorSpecialChar, setPasswordErrorRepeatedChar, setPasswordErrorIsEmail, + setPasswordErrorIsUrl, setPasswordErrorIsBreachedPassword, errorCheck: false }); @@ -259,6 +262,7 @@ export default function PasswordReset() { passwordErrorSpecialChar && passwordErrorRepeatedChar && passwordErrorIsEmail && + passwordErrorIsUrl && passwordErrorIsBreachedPassword } autoComplete="new-password" @@ -273,6 +277,7 @@ export default function PasswordReset() { passwordErrorSpecialChar || passwordErrorRepeatedChar || passwordErrorIsEmail || + passwordErrorIsUrl || passwordErrorIsBreachedPassword ? (
Password should contain:
@@ -369,6 +374,18 @@ export default function PasswordReset() { The password cannot be an email address.
+
+ {passwordErrorIsUrl ? ( + + ) : ( + + )} +
+ The password cannot be a URL. +
+
{passwordErrorIsBreachedPassword ? ( diff --git a/frontend/src/pages/signupinvite.tsx b/frontend/src/pages/signupinvite.tsx index 081dfeadc..105420543 100644 --- a/frontend/src/pages/signupinvite.tsx +++ b/frontend/src/pages/signupinvite.tsx @@ -29,13 +29,15 @@ import { fetchOrganizations } from "@app/hooks/api/organization/queries"; const client = new jsrp.client(); type Errors = { - length?: string; + tooShort?: string; + tooLong?: string; upperCase?: string; lowerCase?: string; number?: string; specialChar?: string; repeatedChar?: string; isEmail?: string; + isUrl?: string; breachedPassword?: string; }; diff --git a/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx index a7611f8bf..69a8d7d4f 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx @@ -21,6 +21,7 @@ type Errors = { specialChar?: string; repeatedChar?: string; isEmail?: string; + isUrl?: string; isBreachedPassword?: string; }; diff --git a/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx b/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx index c159d7784..93143578f 100644 --- a/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx +++ b/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx @@ -41,6 +41,7 @@ type Errors = { specialChar?: string; repeatedChar?: string; isEmail?: string; + isUrl?: string; isBeachedPassword?: string; };