Hey, i added a password confirm input field to the signup form. I didn't find any documented way to validate with another field (password) so i did this way:
typescript
let password = "";
SuperTokensReact.init({
config...,
signInAndUpFeature: {
signUpForm: {
formFields: [
{
id:"passwordConfirm",
validate: async(value:string) => {
if (value !== password) {
return "error msg";
}
return undefined;
}
},
{
id: "password",
validate: async(value:string) => {
password = value;
return undefined;
}
}
]
}
}
})
My question to this. Is it any better way to accomplish this ?
My second problem with this newly created input field is the input type. I got text but i would like to changed this to password, so i did this:
typescript
EmailPasswordReact.init({
override:{
components:{
EmailPasswordSignUpForm_Override:({DefaultComponent}) => {
useEffect(() => {
const passwordConfirm = document.querySelector<HTMLInputElement>('.supertokens-input[name="passwordConfirm"]');
if (passwordConfirm && passwordConfirm.type === "text") {
passwordConfirm.setAttribute("type", "password");
}
}, []);
return <DefaultComponent {...props} />;
}
}
}
})
It worked, but i feel this is not the right way to do it. So is it any better way to do this ?
Thanks for the answers in advance 🙂
Btw i really like the stuff that you guys created 🤘