mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00: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-special-char": "at least 1 special character",
|
||||||
"validate-repeated-char": "at most 2 repeated, consecutive characters",
|
"validate-repeated-char": "at most 2 repeated, consecutive characters",
|
||||||
"validate-is-email": "The password cannot be an email address.",
|
"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."
|
"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": {
|
"token": {
|
||||||
|
|||||||
@@ -237,7 +237,8 @@
|
|||||||
"validate-special-char": "al menos 1 carácter especial",
|
"validate-special-char": "al menos 1 carácter especial",
|
||||||
"validate-repeated-char": "como máximo 2 caracteres repetidos y consecutivos",
|
"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-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": {
|
"token": {
|
||||||
"service-tokens": "Tokens de servicio",
|
"service-tokens": "Tokens de servicio",
|
||||||
|
|||||||
@@ -224,6 +224,7 @@
|
|||||||
"validate-special-char": "au moins 1 caractère spécial",
|
"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-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-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."
|
"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": {
|
"token": {
|
||||||
|
|||||||
@@ -191,7 +191,8 @@
|
|||||||
"validate-special-char": "특수 문자 1개 이상",
|
"validate-special-char": "특수 문자 1개 이상",
|
||||||
"validate-repeated-char": "최대 2개의 반복된 연속 문자",
|
"validate-repeated-char": "최대 2개의 반복된 연속 문자",
|
||||||
"validate-is-email": "비밀번호는 이메일 주소가 될 수 없습니다.",
|
"validate-is-email": "비밀번호는 이메일 주소가 될 수 없습니다.",
|
||||||
"validate-breached": "새 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요."
|
"validate-is-url": "비밀번호는 URL일 수 없습니다.",
|
||||||
|
"validate-is-breached": "새 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요."
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
"add-dialog": {
|
"add-dialog": {
|
||||||
|
|||||||
@@ -219,7 +219,8 @@
|
|||||||
"validate-special-char": "pelo menos 1 caractere especial",
|
"validate-special-char": "pelo menos 1 caractere especial",
|
||||||
"validate-repeated-char": "no máximo 2 caracteres repetidos e consecutivos",
|
"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-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": {
|
"token": {
|
||||||
"service-tokens": "Tokens de Serviço",
|
"service-tokens": "Tokens de Serviço",
|
||||||
|
|||||||
@@ -237,7 +237,8 @@
|
|||||||
"validate-special-char": "en az 1 özel karakter",
|
"validate-special-char": "en az 1 özel karakter",
|
||||||
"validate-repeated-char": "en fazla 2 tekrarlanan, ardışık karakter",
|
"validate-repeated-char": "en fazla 2 tekrarlanan, ardışık karakter",
|
||||||
"validate-is-email": "Şifre bir e-posta adresi olamaz.",
|
"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": {
|
"token": {
|
||||||
"service-tokens": "Servis Belirteçleri",
|
"service-tokens": "Servis Belirteçleri",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type Errors = {
|
|||||||
specialChar?: string;
|
specialChar?: string;
|
||||||
repeatedChar?: string;
|
repeatedChar?: string;
|
||||||
isEmail?: string;
|
isEmail?: string;
|
||||||
|
isUrl?: string;
|
||||||
isBeachedPassword?: string;
|
isBeachedPassword?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import isEmail from "validator/lib/isEmail";
|
import {string} from "yup";
|
||||||
import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
|
import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
|
||||||
|
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
@@ -13,6 +13,7 @@ interface PasswordCheckProps {
|
|||||||
setPasswordErrorSpecialChar: (value: boolean) => void;
|
setPasswordErrorSpecialChar: (value: boolean) => void;
|
||||||
setPasswordErrorRepeatedChar: (value: boolean) => void;
|
setPasswordErrorRepeatedChar: (value: boolean) => void;
|
||||||
setPasswordErrorIsEmail: (value: boolean) => void;
|
setPasswordErrorIsEmail: (value: boolean) => void;
|
||||||
|
setPasswordErrorIsUrl: (value: boolean) => void;
|
||||||
setPasswordErrorIsBreachedPassword: (value: boolean) => void;
|
setPasswordErrorIsBreachedPassword: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ const passwordCheck = async ({
|
|||||||
setPasswordErrorSpecialChar,
|
setPasswordErrorSpecialChar,
|
||||||
setPasswordErrorRepeatedChar,
|
setPasswordErrorRepeatedChar,
|
||||||
setPasswordErrorIsEmail,
|
setPasswordErrorIsEmail,
|
||||||
|
setPasswordErrorIsUrl,
|
||||||
setPasswordErrorIsBreachedPassword,
|
setPasswordErrorIsBreachedPassword,
|
||||||
errorCheck
|
errorCheck
|
||||||
}: PasswordCheckProps) => {
|
}: PasswordCheckProps) => {
|
||||||
@@ -97,13 +99,25 @@ const passwordCheck = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isEmail
|
// isEmail
|
||||||
if (isEmail(password)) {
|
const emailSchema = string().email();
|
||||||
|
|
||||||
|
if (await emailSchema.isValid(password)) {
|
||||||
setPasswordErrorIsEmail(true);
|
setPasswordErrorIsEmail(true);
|
||||||
errorCheck = true;
|
errorCheck = true;
|
||||||
} else {
|
} else {
|
||||||
setPasswordErrorIsEmail(false);
|
setPasswordErrorIsEmail(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isUrl
|
||||||
|
const urlSchema = string().url();
|
||||||
|
|
||||||
|
if (await urlSchema.isValid(password)) {
|
||||||
|
setPasswordErrorIsUrl(true);
|
||||||
|
errorCheck = true;
|
||||||
|
} else {
|
||||||
|
setPasswordErrorIsUrl(false);
|
||||||
|
}
|
||||||
|
|
||||||
// breachedPassword
|
// breachedPassword
|
||||||
if (await checkIsPasswordBreached(password)) {
|
if (await checkIsPasswordBreached(password)) {
|
||||||
setPasswordErrorIsBreachedPassword(true);
|
setPasswordErrorIsBreachedPassword(true);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import isEmail from "validator/lib/isEmail";
|
import {string} from "yup"
|
||||||
import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
|
import { checkIsPasswordBreached } from "./checkIsPasswordBreached";
|
||||||
|
|
||||||
type Errors = {
|
type Errors = {
|
||||||
@@ -10,6 +10,7 @@ type Errors = {
|
|||||||
specialChar?: string;
|
specialChar?: string;
|
||||||
repeatedChar?: string;
|
repeatedChar?: string;
|
||||||
isEmail?: string;
|
isEmail?: string;
|
||||||
|
isUrl?: string;
|
||||||
isBreachedPassword?: string;
|
isBreachedPassword?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,10 +94,19 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isEmail
|
// isEmail
|
||||||
if (isEmail(password)) {
|
const emailSchema = string().email();
|
||||||
|
|
||||||
|
if (await emailSchema.isValid(password)) {
|
||||||
errors.isEmail = "The password cannot be an email address";
|
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
|
// breachedPassword
|
||||||
if (await checkIsPasswordBreached(password)) {
|
if (await checkIsPasswordBreached(password)) {
|
||||||
errors.isBreachedPassword =
|
errors.isBreachedPassword =
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export default function PasswordReset() {
|
|||||||
const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = useState(false);
|
const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = useState(false);
|
||||||
const [passwordErrorRepeatedChar, setPasswordErrorRepeatedChar] = useState(false);
|
const [passwordErrorRepeatedChar, setPasswordErrorRepeatedChar] = useState(false);
|
||||||
const [passwordErrorIsEmail, setPasswordErrorIsEmail] = useState(false);
|
const [passwordErrorIsEmail, setPasswordErrorIsEmail] = useState(false);
|
||||||
|
const [passwordErrorIsUrl, setPasswordErrorIsUrl] = useState(false);
|
||||||
const [passwordErrorIsBreachedPassword, setPasswordErrorIsBreachedPassword] = useState(false);
|
const [passwordErrorIsBreachedPassword, setPasswordErrorIsBreachedPassword] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -81,6 +82,7 @@ export default function PasswordReset() {
|
|||||||
setPasswordErrorSpecialChar,
|
setPasswordErrorSpecialChar,
|
||||||
setPasswordErrorRepeatedChar,
|
setPasswordErrorRepeatedChar,
|
||||||
setPasswordErrorIsEmail,
|
setPasswordErrorIsEmail,
|
||||||
|
setPasswordErrorIsUrl,
|
||||||
setPasswordErrorIsBreachedPassword,
|
setPasswordErrorIsBreachedPassword,
|
||||||
errorCheck: false
|
errorCheck: false
|
||||||
});
|
});
|
||||||
@@ -243,6 +245,7 @@ export default function PasswordReset() {
|
|||||||
setPasswordErrorSpecialChar,
|
setPasswordErrorSpecialChar,
|
||||||
setPasswordErrorRepeatedChar,
|
setPasswordErrorRepeatedChar,
|
||||||
setPasswordErrorIsEmail,
|
setPasswordErrorIsEmail,
|
||||||
|
setPasswordErrorIsUrl,
|
||||||
setPasswordErrorIsBreachedPassword,
|
setPasswordErrorIsBreachedPassword,
|
||||||
errorCheck: false
|
errorCheck: false
|
||||||
});
|
});
|
||||||
@@ -259,6 +262,7 @@ export default function PasswordReset() {
|
|||||||
passwordErrorSpecialChar &&
|
passwordErrorSpecialChar &&
|
||||||
passwordErrorRepeatedChar &&
|
passwordErrorRepeatedChar &&
|
||||||
passwordErrorIsEmail &&
|
passwordErrorIsEmail &&
|
||||||
|
passwordErrorIsUrl &&
|
||||||
passwordErrorIsBreachedPassword
|
passwordErrorIsBreachedPassword
|
||||||
}
|
}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
@@ -273,6 +277,7 @@ export default function PasswordReset() {
|
|||||||
passwordErrorSpecialChar ||
|
passwordErrorSpecialChar ||
|
||||||
passwordErrorRepeatedChar ||
|
passwordErrorRepeatedChar ||
|
||||||
passwordErrorIsEmail ||
|
passwordErrorIsEmail ||
|
||||||
|
passwordErrorIsUrl ||
|
||||||
passwordErrorIsBreachedPassword ? (
|
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="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>
|
<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.
|
The password cannot be an email address.
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div className="ml-1 flex flex-row items-center justify-start">
|
||||||
{passwordErrorIsBreachedPassword ? (
|
{passwordErrorIsBreachedPassword ? (
|
||||||
<FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
|
<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();
|
const client = new jsrp.client();
|
||||||
|
|
||||||
type Errors = {
|
type Errors = {
|
||||||
length?: string;
|
tooShort?: string;
|
||||||
|
tooLong?: string;
|
||||||
upperCase?: string;
|
upperCase?: string;
|
||||||
lowerCase?: string;
|
lowerCase?: string;
|
||||||
number?: string;
|
number?: string;
|
||||||
specialChar?: string;
|
specialChar?: string;
|
||||||
repeatedChar?: string;
|
repeatedChar?: string;
|
||||||
isEmail?: string;
|
isEmail?: string;
|
||||||
|
isUrl?: string;
|
||||||
breachedPassword?: string;
|
breachedPassword?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ type Errors = {
|
|||||||
specialChar?: string;
|
specialChar?: string;
|
||||||
repeatedChar?: string;
|
repeatedChar?: string;
|
||||||
isEmail?: string;
|
isEmail?: string;
|
||||||
|
isUrl?: string;
|
||||||
isBreachedPassword?: string;
|
isBreachedPassword?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type Errors = {
|
|||||||
specialChar?: string;
|
specialChar?: string;
|
||||||
repeatedChar?: string;
|
repeatedChar?: string;
|
||||||
isEmail?: string;
|
isEmail?: string;
|
||||||
|
isUrl?: string;
|
||||||
isBeachedPassword?: string;
|
isBeachedPassword?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user