https://supertokens.com/ logo
#support-questions
Title
# support-questions
i

IaS1506

06/08/2022, 12:09 AM
Hi, I'm trying to do email verification on thirdpartyemailpassword recipe, but it doesn’t work. However, I do everything like in example(with-thirdpartyemailpassword-passwordless) for reactjs.
r

rp

06/08/2022, 4:14 AM
Hey @IaS1506
Can I see your frontend and backend supertokens.init config?
i

IaS1506

06/08/2022, 7:09 AM
frontend
r

rp

06/08/2022, 7:10 AM
hmm. And whats the error?
i

IaS1506

06/08/2022, 7:11 AM
backend
problem is when you sign up with email and password, it redirect to verify-email endpoint
r

rp

06/08/2022, 7:12 AM
Is it possible for you to send the code in text form?
as opposed to images
i

IaS1506

06/08/2022, 7:12 AM
yeah, ок
backend
frontend
and the end problem is that in supertokens example with api it shows form and send email
but with my variant it doesn't do anything
p. s. i use export of FDI Api on backend
j

jscyo

06/08/2022, 7:17 AM
Hey @IaS1506 we are taking a look, will get back to you
i

IaS1506

06/08/2022, 7:17 AM
Ok, thank you
j

jscyo

06/08/2022, 7:21 AM
Hey @IaS1506 as mentioned in the example app you will need to override the
EmailVerificationSendVerifyEmail_Override
component on the frontend as seen here https://github.com/supertokens/supertokens-auth-react/blob/master/examples/with-emailverification-with-otp/src/App.tsx#L43
i

IaS1506

06/08/2022, 7:25 AM
ok, thanks, i will try and then write you how it work
j

jscyo

06/08/2022, 7:26 AM
Alright, if there are any issues please let us know.
i

IaS1506

06/08/2022, 7:27 AM
Another issue that i cant use my otpservice inside passwordless recipe initialization
it says that cannot acces to the private variable of supertokens service
j

jscyo

06/08/2022, 7:30 AM
Hey, could you show me in your code where you are having this issue
i

IaS1506

06/08/2022, 7:31 AM
in constructor i define otpService
but in sendcustomemail i have not access to it by "this"
j

jscyo

06/08/2022, 7:36 AM
Its cause otpService is not part of SuperTokens, can you show me where you are defining otpService
i

IaS1506

06/08/2022, 7:39 AM
and in auth module i defined imports
import { DynamicModule, MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; import { AuthModuleConfig, ConfigInjectionToken } from './config.interface'; import { SupertokensAuthService } from './supertokens-auth-service/supertokens-auth.service'; import { SupertokensAuthMiddleware } from './supertokens-auth.middleware'; import { OtpService } from '../otp/otp.service'; @Module({ providers: [SupertokensAuthService, OtpService], exports: [], controllers: [] }) export class SupertokensAuthModule implements NestModule { configure(consumer: MiddlewareConsumer) { consumer.apply(SupertokensAuthMiddleware).forRoutes('*'); } static forRoot({ connectionURI, apiKey, appInfo }: AuthModuleConfig): DynamicModule { return { providers: [ { useValue: { appInfo, connectionURI, apiKey }, provide: ConfigInjectionToken } ], exports: [], imports: [OtpService], module: SupertokensAuthModule }; } }
r

rp

06/08/2022, 7:40 AM
can you please format the code properly?
j

jscyo

06/08/2022, 7:43 AM
You should be able to import
OtpService
where you define your backend code and call it in your
createAndSendCustomEmail
function without using
this
i

IaS1506

06/08/2022, 4:11 PM
Hi, I have another one issue in thirdpartyemailpassword. I post endpoint /user/email/verify/token and then get an error of supertokens core: "code":422,"message":"SuperTokens core threw an error for a GET request to path: '/recipe/user' with status code: 400 and message: Please provide one of userId or email\n". I have 9.2.3 version of SDK, so what is wrong with this recipe?
r

rp

06/08/2022, 4:12 PM
Can i see the request you sent?
Try adding a Content-Type: application/json header as well?
i

IaS1506

06/08/2022, 4:16 PM
And how can i do it?
Thats a post operation to endpoint and error in response
So, where should i set content type application/json header?
r

rp

06/08/2022, 4:37 PM
how are you sending the reqyuest? postman? curl? fetch? axios?
i

IaS1506

06/08/2022, 4:38 PM
With your API, not with postman, curl, fetch or axios
Using swagger
recipe emailpassword works correctly but thirdpartyemailpassword does not work
r

rp

06/08/2022, 4:42 PM
well.. swagger can be a bit inaccurate.
you also need to pass in the sAccessToken
in the cookies
i

IaS1506

06/08/2022, 4:44 PM
I am using same values of sAccessToken and sIdRefreshToken for both tests: emailpassword and thirdpartyemailpassword. But result is different.
r

rp

06/08/2022, 4:44 PM
which recipes are you initialising on the frontend and backedn?
You need to stick to the same recipes on frontend and backend
i

IaS1506

06/08/2022, 4:45 PM
as result I should add EmailPassword.init but I want to use ThirdPartyEmailPassword.init only
r

rp

06/08/2022, 4:46 PM
Im gonna need more info about this. Can we get on a quick call?
i

IaS1506

06/08/2022, 4:46 PM
go
r

rp

06/08/2022, 4:47 PM
Join Zoom Meeting https://us06web.zoom.us/j/85383174603?pwd=YnJQWXJBYmVPd05uU0g1RDZ2aGtvUT09 Meeting ID: 853 8317 4603 Passcode: 439919 One tap mobile +13462487799,,85383174603#,,,,*439919# US (Houston) +16699006833,,85383174603#,,,,*439919# US (San Jose) Dial by your location +1 346 248 7799 US (Houston) +1 669 900 6833 US (San Jose) +1 929 205 6099 US (New York) +1 253 215 8782 US (Tacoma) +1 301 715 8592 US (Washington DC) +1 312 626 6799 US (Chicago) Meeting ID: 853 8317 4603 Passcode: 439919 Find your local number: https://us06web.zoom.us/u/kcLiwGi4a9
i

IaS1506

06/08/2022, 5:20 PM
Yeah, everything alright now, thank you
r

rp

06/08/2022, 5:36 PM
ok awesome!
@IaS1506 you tried the demo app from the other branch?
i

IaS1506

06/08/2022, 5:49 PM
Yeah, from account-linking branch, it now works for me
r

rp

06/08/2022, 5:50 PM
ok great. Just a quick note, that demo app is not complete and has fairly complex customisations.
We are working on making account linking easier. But should take ~1-2 months.
i

IaS1506

06/08/2022, 5:51 PM
Yeah, I saw it, but I have not much time, so I think that I will have to improve it faster
)
But then i will be waiting for this)
r

rp

06/08/2022, 5:53 PM
cool!
i

IaS1506

06/09/2022, 9:38 AM
Hi, now i have a question - how to do account linking correctly). In my situation 1 I register an account with email "test" by thirdparty and then register with emailpassword. This will create two separate users with same email without same primary user(and passwordless with this email wont work). In another situation 2 I register at first user with email by emailpassword and then user with the same email wont register by thirdparty(email exists error). I remember that you said its raw functionality, but do ypu have any idea how to fix it?)
r

rp

06/09/2022, 9:43 AM
the demo app should do account linking properly if the emails are verified. Whcih demo app are you using?
If you register a user in email password, make sure to also verify their email before. If verification is not done, the account won't be linked.
i

IaS1506

06/09/2022, 9:54 AM
i tried another scenario, i register user with email "test" as passwordless and its create user with primary-user prefix, then i register with thirdparty with the same email and its create user with the same primary-user prefix, then I register user with email password by: 1. Send verification mail with otp code 2. Check otp code from form 3. Create user with verified mail - this creates user without primary-user prefix
r

rp

06/09/2022, 9:55 AM
you need to go through our email verification flow for it to work - are you doing that?
i

IaS1506

06/09/2022, 9:57 AM
ooops... I will add this now
can you help me with this, I just added all functionality, but user still creates without primary-user ...(
r

rp

06/09/2022, 10:45 AM
can you run the demo app without any of your customisations and then try and login?
it will be difficult for me to go into your custom setup and help you out
i

IaS1506

06/09/2022, 10:56 AM
:/ Ok
r

rp

06/09/2022, 10:57 AM
when the default app works as expected, then you can start to add your customisations on top of it one by one, and for that, I can help 🙂
i

IaS1506

06/13/2022, 10:06 PM
Hi, I have question. How can I override password hashing algorithm?
And can i even do it
?)
r

rp

06/14/2022, 4:05 AM
Hey @IaS1506 we have two of them by default - bcryt and argon2. If you don’t want to use either, you can override the signIn, signUp, resetPassword recipe functions on the backend to do your own hashing before calling the original implementation. This will essentially apply two hashes to a plaintext password: one which you do, and one which the core does. So I’m effect, the security of the password hash is equivalent to the max security of both the hashes applied to it.
i

IaS1506

06/15/2022, 12:31 PM
ok, i suupose that it's clear
And one another question: is there in your examples repository workable solution for integrating own reset password functionality?
r

rp

06/15/2022, 12:54 PM
you mean your own custom UI? Or something else?
i

IaS1506

06/15/2022, 1:06 PM
I mean I want when I press "Reset password", I go to email entering page and then i want to generate otp for reset password and link to otp form, then enter otp and go to "new password" form, enter new password and then get to login page
r

rp

06/15/2022, 1:07 PM
ah right. So it's a different way of doing password reset. We use links for password reset, not OTP.
Whilst you can cusotmise supertokens to use OTPs instead of links, you will have to store and manage the OTPs yourself.
i

IaS1506

06/15/2022, 1:09 PM
I have managed otp for email verefication already
But i had a schema for email verification, what i need to do to get workable solution in your examples
For reset password i have not found any of examples with it
So my problem is to know what i have to use to integrate it with myself
r

rp

06/15/2022, 1:17 PM
ah rigth. We don't have an example for it, but it would be similar to how you did for email verification
there will be equivalent functions related to reset password that you would need to override
i

IaS1506

06/15/2022, 1:40 PM
ok, I resulted to send me reset password code to email
but i see next screen
what should i override to see otpscreen instead?
r

rp

06/15/2022, 1:43 PM
Which recipe are you iusing again?
i

IaS1506

06/15/2022, 1:43 PM
thirdpartyemailpassword
r

rp

06/15/2022, 1:44 PM
You should override
EmailPasswordResetPasswordEmail_Override
this will allow you to change the form in which the email is entered, and the form which shows the above message in your screenshot
i

IaS1506

06/15/2022, 1:50 PM
ok, but i have misunderstanding: I should see form of entering email, then screenshot, then new password. So if i override EmailPasswordResetPasswordEmail_Override, how can i link behaviour for redirecting to otp form and then to new-password form?
r

rp

06/15/2022, 1:52 PM
On the frontend, you can override the recipe function that sends the password reset email and then post calling the original implementatino, you can redirect the user to your ewnter OTP form
i

IaS1506

06/15/2022, 1:53 PM
ok, i will try it, thanks
ok, sorry for lots of questions, but when i considered to use links (as your default variant) i get unathorized exception. It is logical, bc user does not have session when he is not logined, so how can i resolve it: create temporary session or you already had similar mechanism?
r

rp

06/15/2022, 2:19 PM
this is for email verification or reset password?
i

IaS1506

06/15/2022, 2:19 PM
reset password
r

rp

06/15/2022, 2:20 PM
hmm. reset password should not require a session
if you are using the token to reset a password
i

IaS1506

06/15/2022, 2:23 PM
🤔
ah, it's my fault, sorry
a

Atoyebs

06/15/2022, 11:58 PM
Hi @rp, is there currently a way to manually trigger the sending of a verification email when using a custom UI? In my case i've built a custom UI for both login and signup. I've got both working through using the sdk. After a user is successfully authenticated for login I direct them to / which routes them to auth/verify-email because the email hasn't been verified yet. From my read of the docs, the email doesn't seem to be sending automagically because i'm using my own custom UI (which isn't manually overriding my frontend config) my UI components are separate to the frontendConfig. I see this function: https://supertokens.com/docs/auth-react/modules/recipe_thirdpartyemailpassword.html#sendVerificationEmail But my guess is that I can use this with overriding the frontendConfig, my question is . . . can I use this method or send the verification email with my custom UI? and if so, how?
r

rp

06/16/2022, 5:42 AM
You can use this method in your own UI. Just do
await ThirdPartyEmailPassword.sendVerificationEmail()
and that should call the API that generates and sends an email verification email to the currently logged in user.
a

Atoyebs

06/16/2022, 9:41 AM
Thanks for this @rp
3 Views