kazumo
05/23/2023, 6:12 AMrp_st
05/23/2023, 6:13 AMkazumo
05/23/2023, 6:19 AMrp_st
05/23/2023, 6:37 AMkazumo
05/23/2023, 11:59 AMrecipeList: [
ThirdPartyEmailPasswordReact.init({
signInAndUpFeature: {
signUpForm: {
formFields: [
{
id: 'password',
label: '...',
validate: async (pw) => {
console.log(pw);
let isValidLength = true;
if (pw.length < MIN_PASSWORD_LENGTH || pw.length > MAX_PASSWORD_LENGTH) {
isValidLength = false;
}
let isAllHalfWidth = true;
const includeInvalidCharRegex = /[^a-zA-Z0-9\x01-\x7E\uFF61-\uFF9F]{1,}/;
const includeSingleByteKanaRegex = /[ヲ-゚]{1,}/;
if (includeInvalidCharRegex.test(pw) || includeSingleByteKanaRegex.test(pw)) {
isAllHalfWidth = false;
}
const includeNumberRegex = /[0-9]{1,}/;
const includeLowerAlphabetRegex = /[a-z]{1,}/;
const includeUpperAlphabetRegex = /[A-Z]{1,}/;
const includeSymbolRegex = /[\x20-\x2F\x5B-\x60\x7B-\x7F]{1,}/;
let matchCount = 0;
[
includeNumberRegex,
includeLowerAlphabetRegex,
includeUpperAlphabetRegex,
includeSymbolRegex,
].forEach((regex) => {
if (regex.test(pw)) matchCount++;
});
if (matchCount > 2 && isValidLength && isAllHalfWidth) {
// Your own validation returning a string or undefined if no errors.
return undefined;
} else {
return 'invalid password';
}
},
},
],
},
},
}),
SessionReact.init(),
],
rp_st
05/23/2023, 12:00 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by