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

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 3:44 PM
Hey, I have 2 questions: 1) What do you mean with: "You can also provide the table schema by providing the POSTGRESQL_TABLE_SCHEMA option." (https://supertokens.com/docs/thirdpartyemailpassword/custom-ui/init/database-setup/postgresql) ? I have users in public."Users" table ( and my url to db end on "?schema=public&sslmode=prefer". 2) I'm trying to add email verification. I want to use Sendgrid with domain, not smtp but I don't know how I should configure. How should I configure?
r

rp

01/25/2023, 3:47 PM
Hey @γƒ”γƒ§γƒˆγƒ«πŸΊ
1) you don’t need to provide that config cause the default schema is public
2) see the email delivery section in docs. Specifically the custom method part.
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 3:50 PM
2) I read but I don't understand,
r

rp

01/25/2023, 3:50 PM
I’m not sure how better to explain the concept than what’s in the docs
You need to override the sendEmail function to use sendgrid
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 3:58 PM
so default POSTGRESQL_TABLE_SCHEMA is "public"?
r

rp

01/25/2023, 3:58 PM
Yes
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 4:01 PM
If I write the function according to the Sendgrid documentation i.e. their Web API how will SuperTokens know that the user has clicked on the link? And how should I create this activation link to make it secure? I only know it must be dynamic.
I see.
r

rp

01/25/2023, 4:03 PM
The verification link is the input to the sendEmail function. You need to make an email template with that link and send via sendgrid.
When the user clicks on the link, it opens your frontend website and our pre built ui consumes the link
It’s all in the docs. Please have a look. I can only help answer very specific questions at the moment.
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 4:09 PM
I see, so frontend sdk will see this link. I'll try to do this and if I'll have a problem I write again.
r

rp

01/25/2023, 4:09 PM
Sounds good
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 4:11 PM
aaa and when I override sendEmail, backend sdk will see link too and add (and delete after click in link) to relevant table?
r

rp

01/25/2023, 4:11 PM
Yes.
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 4:20 PM
I see. Thanks :)
aa I use custom ui, not prebuilt ui I forgot to write itπŸ˜…
r

rp

01/25/2023, 4:59 PM
We have guides for custom ui email verification as well. Check those out
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 5:22 PM
ah, I was reading in wrong place xd I need to override originalImplementation.sendEmail or sendEmail? in https://supertokens.com/docs/emailpassword/custom-ui/enable-email-verification#changing-the-email-verification-link-domain--path and whether if I have REQUIRED or OPTIONAL?
r

rp

01/25/2023, 5:22 PM
Yes
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 5:33 PM
originalImplementation.sendEmail or sendEmail?
r

rp

01/25/2023, 5:34 PM
sendEmail.
You don’t need to call oroginalImplementation.sendEmail
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/25/2023, 5:37 PM
I see.
Hey, I still have a problem. I have so: https://gist.github.com/jukialen/5197840d37023523007b9eabca7f0af4 now and I don't know what I do wrong.
I use Nestjs and prisma.
@porcellus Can you help me?
r

rp

01/26/2023, 11:54 AM
Hey. We can’t help unless you are specific in your question. Sorry
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 11:58 AM
I want to override sendMail funcion to send email via Sendgrid and I need convey proprs to my sendMail function,
r

rp

01/26/2023, 11:58 AM
Custom props?
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 11:59 AM
Yes. I have: templateVersion, verificationUrl and email.
r

rp

01/26/2023, 12:00 PM
So the verification url and email are part of the input itself
Template version, how do you determine that?
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 12:03 PM
input.verificationUrl and input.email? I think, that 1 function for verification email and forgot password is good programiing idea. This is id for dynamic template id.
I have object with ids and I'll use in this props: template.someNameId
Do you understand? I was trying but I cannot do this (override with props).
Can you help me after these details? πŸ˜…
Now I have: override: (originalImplementation) => { return { ...originalImplementation, sendEmail(input) { return send({ templateVersion: templates.confirmEmail, verificationUrl: input.url, email: input.email, }); }, }; }, but I have this error: "TS2560: Value of type '(originalImplementation: any) => any' has no properties in common with type '{ functions?: (originalImplementation: RecipeInterface, builder?: OverrideableBuilder) => RecipeInterface; apis?: (originalImplementation: APIInterface, builder?: OverrideableBuilder) => APIInterface; }'. Did you mean to call it?"
p

porcellus

01/26/2023, 12:51 PM
So as the first error shows, the sendEmail override shouldn't be there (on that level it should be an object). It's supposed to go inside the emailDelivery config. Please check out our docs: https://supertokens.com/docs/thirdpartyemailpassword/email-delivery/custom-method
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 1:49 PM
I accidentally deleted "emailDelivery: {" xddd
Now I have so: ThirdPartyEmailPassword.init({ providers: [ ThirdPartyEmailPassword.Google({ clientId: process.env.GOOGLE_ID, clientSecret: process.env.GOOGLE_SECRET_ID, }), ], emailDelivery: { override: () => { return { // ...originalImplementation, sendEmail: async function ( input, ): Promise< | { statusCode: HttpStatus; message: string } | BadRequestException > { return send({ templateVersion: templates.forgottenPassword, verificationUrl: input.passwordResetLink, email: input.user.email, }); }, }; }, }, }), EmailVerification.init({ mode: 'OPTIONAL', emailDelivery: { override: () => { return { // ...originalImplementation, sendEmail: async function ( input, ): Promise< | { statusCode: HttpStatus; message: string } | BadRequestException > { return send({ templateVersion: templates.confirmEmail, verificationUrl: input.emailVerifyLink, email: input.user.email, }); }, }; }, }, }), Maybe now is ok? I only have errors with types.
r

rp

01/26/2023, 1:50 PM
If you have errors in types, you should fix them.
I’m sure you can figure it out. The docs are clear enough. Thanks
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 1:57 PM
But this code already is ok? I should can fix types errors although they are strange.
r

rp

01/26/2023, 2:07 PM
I’m not sure if the code is ok. See our docs please.
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 2:13 PM
I only mean if my function override is ok. My send function is another topic.
r

rp

01/26/2023, 2:13 PM
Seems fine. Test it out though
u

γƒ”γƒ§γƒˆγƒ«πŸΊ

01/26/2023, 5:20 PM
Yes. When I manage to fix the bugs with the types, I will test the whole authentication.