mirror of
https://github.com/Infisical/infisical.git
synced 2026-05-02 03:02:03 -04:00
>>> yup for email & url validation, fixed minor err in error msgs
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -46,6 +46,7 @@ type Errors = {
|
||||
specialChar?: string;
|
||||
repeatedChar?: string;
|
||||
isEmail?: string;
|
||||
isUrl?: string;
|
||||
isBeachedPassword?: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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 ? (
|
||||
<div className="mx-2 mt-3 mb-2 flex w-full max-w-md flex-col items-start rounded-md bg-white/5 px-2 py-2">
|
||||
<div className="mb-1 text-sm text-gray-400">Password should contain:</div>
|
||||
@@ -369,6 +374,18 @@ export default function PasswordReset() {
|
||||
The password cannot be an email address.
|
||||
</div>
|
||||
</div>
|
||||
<div className="ml-1 flex flex-row items-center justify-start">
|
||||
{passwordErrorIsUrl ? (
|
||||
<FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
|
||||
) : (
|
||||
<FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
|
||||
)}
|
||||
<div
|
||||
className={`${passwordErrorIsUrl ? "text-gray-400" : "text-gray-600"} text-sm`}
|
||||
>
|
||||
The password cannot be a URL.
|
||||
</div>
|
||||
</div>
|
||||
<div className="ml-1 flex flex-row items-center justify-start">
|
||||
{passwordErrorIsBreachedPassword ? (
|
||||
<FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ type Errors = {
|
||||
specialChar?: string;
|
||||
repeatedChar?: string;
|
||||
isEmail?: string;
|
||||
isUrl?: string;
|
||||
isBreachedPassword?: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ type Errors = {
|
||||
specialChar?: string;
|
||||
repeatedChar?: string;
|
||||
isEmail?: string;
|
||||
isUrl?: string;
|
||||
isBeachedPassword?: string;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user