Hi, Can I overrode email and password validation? ...
# general
w
Hi, Can I overrode email and password validation? I have: emailPasswordSignUp: async function (input) { const existingUsers = await ThirdPartyEmailPassword.getUsersByEmail(input.email); if (existingUsers.length === 0) { const inputWithGoodValues: SuperTokensUsersPipe = { email: input.email, password: input.password, }; return originalImplementation.emailPasswordSignUp({ email: inputWithGoodValues.email, password: inputWithGoodValues.password, userContext: input.userContext, }); } return { status: 'EMAIL_ALREADY_EXISTS_ERROR', }; }, but this is ignoring.
r
hey @weboux
which recipe?
w
ThirdPartyEmailPassword
r
Can I see the full thirdpartyemailpassword.init?
w
ok
Discord converted text to txt file xd
r
Hmmm. So the override is not getting called at all?
w
I don't know so I asked here.
r
Can you add a console log at the start of the override and then call the email password sign up API?
w
I added: https://supertokens.com/docs/thirdpartyemailpassword/troubleshooting/how-to-troubleshoot but happened nothing :/ I even have " 11 Feb 2023 16:45:38:635 +0000 | INFO | pid: 709432c2-c889-4cf1-948b-45a6f706acf9 | [http-nio-0.0.0.0-3567-exec-2] thread | io.supertokens.webserver.WebserverAPI.service(WebserverAPI.java:186) | API ended: /telemetry. Method: GET " When I use sign up, I get: { "status": "FIELD_ERROR", "formFields": [ { "error": "Password must contain at least 8 characters, including a number", "id": "password" } ] } I should be 9 and has big chars too.
By the way, I found out that it doesn't fire up my email sending.
emailDelivery: { override: () => { return { sendEmail: async function (input) { const data = await usersService.users({ where: { id: input.user.id }, }); await send({ templateVersion: templates.forgottenPassword, verificationUrl: input.passwordResetLink, email: input.user.email, emails: emails.forgottenPasswordEmail, title: titles.forgotten, username:
${data[0].username}!
, }); }, }; }, }, }),
r
I’m not sure why these functions aren’t working for you. There may be something small that’s misconfigured
I would suggest that you see one of our example apps from our cli
And use that as a basis to start
If you are getting a field error during sign up, try a password like abcd1234. That should work
If it doesn’t, try and step through the stack.
w
wrong last code xd
EmailVerification.init({ mode: 'REQUIRED', emailDelivery: { override: () => { return { sendEmail: async function (input) { await send({ templateVersion: templates.confirmEmail, verificationUrl: input.emailVerifyLink, email: input.user.email, emails: emails.confirmEmail, title: titles.confirm, username: '', }); }, }; }, }, }),
This is ok
r
I’m not sure I can help out anymore cause your questions are very vague and I can’t really see your app’s code
w
I only mean validation user. I create users correct
r
I’m not sure I understand
If you want to change validation rules, checkout the section in our docs about form field validators
w
Ok, I'll check
I override email delivery but when user is created, this isn't work. My function is not called and I don't know why.
@rp_st do you know why?
Logs from creating (correct) user: i { email: 'support@pfartists.xyz', password: 'tessqqq1', userContext: { _default: { request: [ExpressRequest] } } } exist [] new { email: 'support@pfartists.xyz', password: 'tessqqq1' }
r
Email verification is a different api. It’s not the same as the sign up api
w
"exist []" so this user doesn't exist
r
Please see our guides for custom ui, please see our demo apps.
w
Can you add link? I was thinking that if I have REQUIRED, this function 'll work after created user :/
r
You need to call our email verification api from the frontend
The required mode essentially adds the email verification status into the session and makes the verifySession function check for the status
w
SO when user do sign up, I need ... what? :/ I'm starting to get lost. ANd I don't check in POstman? I'm using https://supertokens.com/docs/thirdpartyemailpassword/testing/testing-with-postman
r
See our guide for building your own ui please
If you are using our pre built ui, then all the email verification stuff happens on its own
And you can follow the api calls in the network tab
w
I already found but you already sent before me xddd I've had to embrace verylot lately xdd I think I need to slow down xd
And can I somehow get the email sending to work in Postman or is that impossible?
r
Yes. U can. Call the login api first in postman. And then call the send email api
w
Can you add api name or link? 😅
r
Please see our api spec
Supertokens.com/docs/fdi
w
Thanks 🙂
@rp_st I'll let it go xd I don't know what exactly the "body" of the request should look like and how to do the token to avoid problems. I only know that the token has 128 characters. But I learned something again. Thanks for your help :)