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

shubham vora

04/20/2022, 5:38 AM
I am implementing the passwordless authentication using supertokerns. So, for backend, from the example given on github, I have to add api-server/index.js file and mailer.js file? or only implement index.js file? and supertoken will send mail to users?
n

nkshah2

04/20/2022, 5:41 AM
I am implementing the passwordless authentication using supertokerns. So, for backend, from the example given on github, I have to add api-server/index.js file and mailer.js file? or only implement index.js file? and supertoken will send mail to users?
You only need to follow the steps mentioned here (https://supertokens.com/docs/passwordless/quick-setup/backend) to get the setup done. Following those steps is enough to get auth up and running on the backend
s

shubham vora

04/20/2022, 5:42 AM
3rd step is confusing in this. can you explain it?
n

nkshah2

04/20/2022, 5:44 AM
Ah I see what you mean, yes you will need to implement your own version for sending mails and SMS. You can refer to the
mailer.js
file for that
s

shubham vora

04/20/2022, 5:44 AM
no, i got it. so, i will follow docs after if i make request on given route? it will work fine, am is right?
n

nkshah2

04/20/2022, 5:44 AM
Yes
s

shubham vora

04/20/2022, 5:45 AM
ok, thanks!
when i am mergin the code of 3rd step, it showing me error like this.
n

nkshah2

04/20/2022, 5:53 AM
The code you used has type annotations
variableName: Type
. That is not supported in JS files. The documentation is indicating what the type of the variables should be but you will have to change the values for it
s

shubham vora

04/20/2022, 5:54 AM
like! can you give example?
n

nkshah2

04/20/2022, 5:54 AM
Copy code
createAndSendCustomEmail: async function (input) {
                let htmlBody = getEmailBody(
                    APP_NAME,
                    Math.ceil(input.codeLifetime / 1000),
                    input.urlWithLinkCode,
                    input.userInputCode,
                    input.email
                );
                await mailTransporter.sendMail({
                    html: htmlBody,
                    to: input.email,
                    from: `Team Supertokens <${process.env.NODEMAILER_USER}>`,
                    sender: process.env.NODEMAILER_USER,
                    subject: `Login to ${APP_NAME}`,
                });
            },
From the mailer file in the example you linked to
s

shubham vora

04/20/2022, 5:55 AM
ya! I see it, so i asked that i have to connect mailer file also?
n

nkshah2

04/20/2022, 5:55 AM
Yes you do
s

shubham vora

04/20/2022, 5:56 AM
Ok. After if i will make request from post man, it will work fine. right?
n

nkshah2

04/20/2022, 5:56 AM
Yep
s

shubham vora

04/20/2022, 5:57 AM
thanks!
n

nkshah2

04/20/2022, 5:57 AM
Happy to help
s

shubham vora

04/20/2022, 5:57 AM
maybe i will need more!
i am not confident still
n

nkshah2

04/20/2022, 5:57 AM
Sure, feel free to ask if you have more questions
s

shubham vora

04/20/2022, 5:57 AM
ok
can you tell me something about this error?
n

nkshah2

04/20/2022, 6:16 AM
have you followed all the steps in the quick setup guide?
s

shubham vora

04/20/2022, 6:16 AM
ya
i can share a code file also if you want
and copied whole mailer.js file
here is the code
Now, I have copied index.js file also and trying to send post request. let's see what happens
n

nkshah2

04/20/2022, 6:21 AM
@porcellus Can probably help better here
s

shubham vora

04/20/2022, 6:21 AM
still giving same error
n

nkshah2

04/20/2022, 6:26 AM
The mailer file expects environment variables to be set for the email user and password, have you set those?
s

shubham vora

04/20/2022, 6:26 AM
ya i am sending same message to you!
but how to set it?
n

nkshah2

04/20/2022, 6:27 AM
create a
.env
file in the api-server folder
s

shubham vora

04/20/2022, 6:27 AM
ok, and then which username and password i should add?
my email account?
n

nkshah2

04/20/2022, 6:27 AM
In that file add the two things it expects
Copy code
NODEMAILER_USER=
NODEMAILER_PASSWORD=
Yep
s

shubham vora

04/20/2022, 6:27 AM
got it.
n

nkshah2

04/20/2022, 6:27 AM
The account you want the emails to be sent from
s

shubham vora

04/20/2022, 6:28 AM
yeap
bcz still it is giving error.
n

nkshah2

04/20/2022, 6:33 AM
What error are you seeing?
s

shubham vora

04/20/2022, 6:33 AM
same.
n

nkshah2

04/20/2022, 6:33 AM
Also deleting the screenshot because it contains credentials
s

shubham vora

04/20/2022, 6:33 AM
no its not right
n

nkshah2

04/20/2022, 6:34 AM
Did you restart the backend server after creating the
.env
file?
s

shubham vora

04/20/2022, 6:34 AM
nope. let me try
r

rp

04/20/2022, 6:35 AM
Hey! So that happens if you do not give credentials for your smtp setting when using nodemailer
n

nkshah2

04/20/2022, 6:48 AM
@shubham vora Did restarting the server work?
s

shubham vora

04/20/2022, 6:52 AM
Sir, i have lec in my clg. So, i came here. But i will do it after 2 hours.
n

nkshah2

04/20/2022, 6:52 AM
ah alright
s

shubham vora

04/20/2022, 7:43 AM
it shows me this error. However, i toggle on less secure signin for less secure apps.
n

nkshah2

04/20/2022, 7:43 AM
Its saying your credentials dont match
s

shubham vora

04/20/2022, 7:44 AM
but's i have reset it recently
r

rp

04/20/2022, 7:44 AM
@shubham vora I think the issue is with your credentials now. It's out of scope of supertokens' issue 🙂
You can google how to solve issues related to nodemailer
s

shubham vora

04/20/2022, 7:45 AM
Ya! doing it.
solved!
r

rp

04/20/2022, 7:45 AM
If there are any supertokens related issues, please feel free to ask. But we would really appreciate it if you try and solve it yourself first, or google to get the answer 🙂 Thank you
s

shubham vora

04/20/2022, 7:45 AM
ok!
Hi sir, How can i use frontend template in passwordless authentication with svelte?
There is a example for react but i want to use it in svelete.
r

rp

04/20/2022, 10:27 AM
You will have to build your own UI for that
s

shubham vora

04/20/2022, 10:32 AM
Ok. Thanks!
can you send the any documents to apply the custom UI of the passwordless recipe?
Also, when i am clicking on the login link, it is not redirecting me anywhere. what is the problem? I have copied same file index.js and mailer.js
r

rp

04/20/2022, 1:47 PM
What version of the frontend SDK are you using?
s

shubham vora

04/20/2022, 1:48 PM
latest one
r

rp

04/20/2022, 1:48 PM
Are you getting the cookies back?
s

shubham vora

04/20/2022, 1:48 PM
response?
r

rp

04/20/2022, 1:48 PM
Yes
s

shubham vora

04/20/2022, 1:48 PM
yes
mail also getting
but link is not working
and not authenticating
r

rp

04/20/2022, 1:49 PM
I need more info. What is the API response? Can you enable debug logging on the backend and show the logs?
s

shubham vora

04/20/2022, 1:49 PM
see last response. it is fine
when i click on login link from email. it shows like this but not redirecting
and copied the both backend file from github and making request from postman
here it is given that when user clicks on the magic link, make post request. should i try to find solution to make post request while clicking on it?
r

rp

04/20/2022, 2:12 PM
Yes. You need to make that post request