How to handle the cosequent requests using JWT after authenticating via Magic Login in Passport.js

15 Views Asked by At

My requirement is to use magic login method (send an email to login to the system via link). Once the user is authenticated, server sends the JWT token to the client. So consequent requests made to the server will be authorized by the JWT.

I've being following official magic link guide however, by default it complains to install express-session to handle the session. However, when the session is set to false, response of the /magiclogin/callback will become 404.

router.get(
    '/magiclogin/callback',
    authPassport.authenticate('magiclogin', {
        session: false,
    })
)

How can I,

  • Send back a newly generated token using jsonwebtoken from the /magiclogin/callback endpoint in a way that passport-jwt is compatible?

From the documentation, it's not clear to me how to manually handle the session process.

0

There are 0 best solutions below