Hey. I'm trying to implement Passwordlaess method ...
# general
l
Hey. I'm trying to implement Passwordlaess method with email and magic link with custom vue UI
r
hey @Leonxx
@nkshah2 can help here
l
ok tnx
n
Hi, So for magic links you want to do the following: 1. Initialise the Passwordless recipe
Copy code
import Session from "supertokens-web-js/recipe/session"
import Passwordless from "supertokens-web-js/recipe/passwordless"

SuperTokens.init({
    appInfo: {
        apiDomain: "...",
        appName: "...",
    },
    recipeList: [
        Session.init(),
        Passwordless.init()
    ],
});
2. Send the user an email with the magic link/code
Copy code
Passwordless.createCode({email: ""}) // or use {phoneNumber: ""}
This will send an email to the user (If you configure the recipe to use magic links on the backend, the email will use magic links) 3. When the user visits your frontend (using the magic link in the email), you can use
consumeCode
to log the user in
Copy code
Passwordless.consumeCode()
The createCode function reads the information from the magic link internally
l
consumeCode without any parameters?
n
Yep
It reads from the current location which will be the magic link url
l
ok let me try
I'm using TS and consumeCode function needs to have a parameter.
n
You can use an empty object as a parameter
l
ok. so there is some progress. When I click on the ML from the email. I'm redirected to /auth path but I dont have a active session
n
Do you mean you dont see any cookies in your browser?
l
only this one
n
Can you log the response of
Passwordless.consumeCode()
l
It's working just need to provide a verify path inside the router
n
Ah I see
l
OTP is much more straight forward
Thank you so much.
4 Views