I am implementing the passwordless authentication ...
# support-questions-legacy
s
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
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
3rd step is confusing in this. can you explain it?
n
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
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
Yes
s
ok, thanks!
when i am mergin the code of 3rd step, it showing me error like this.
n
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
like! can you give example?
n
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
ya! I see it, so i asked that i have to connect mailer file also?
n
Yes you do
s
Ok. After if i will make request from post man, it will work fine. right?
n
Yep
s
thanks!
n
Happy to help
s
maybe i will need more!
i am not confident still
n
Sure, feel free to ask if you have more questions
s
ok
can you tell me something about this error?
n
have you followed all the steps in the quick setup guide?
s
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
@porcellus Can probably help better here
s
still giving same error
n
The mailer file expects environment variables to be set for the email user and password, have you set those?
s
ya i am sending same message to you!
but how to set it?
n
create a
.env
file in the api-server folder
s
ok, and then which username and password i should add?
my email account?
n
In that file add the two things it expects
Copy code
NODEMAILER_USER=
NODEMAILER_PASSWORD=
Yep
s
got it.
n
The account you want the emails to be sent from
s
yeap
bcz still it is giving error.
n
What error are you seeing?
s
same.
n
Also deleting the screenshot because it contains credentials
s
no its not right
n
Did you restart the backend server after creating the
.env
file?
s
nope. let me try
r
Hey! So that happens if you do not give credentials for your smtp setting when using nodemailer
n
@shubham vora Did restarting the server work?
s
Sir, i have lec in my clg. So, i came here. But i will do it after 2 hours.
n
ah alright
s
it shows me this error. However, i toggle on less secure signin for less secure apps.
n
Its saying your credentials dont match
s
but's i have reset it recently
r
@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
Ya! doing it.
solved!
r
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
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
You will have to build your own UI for that
s
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
What version of the frontend SDK are you using?
s
latest one
r
Are you getting the cookies back?
s
response?
r
Yes
s
yes
mail also getting
but link is not working
and not authenticating
r
I need more info. What is the API response? Can you enable debug logging on the backend and show the logs?
s
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
Yes. You need to make that post request
2 Views