-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
The href being generated by the sendMagicLink function seems be adding 'undefined' before the question mark and token=.
Here is my strategy:
const magicLogin = new MagicLoginStrategy({
secret: process.env.MAGIC_LINK_SECRET,
callbackURL: '/auth/magiclogin/callback',
sendMagicLink: async (destination, href) => {
try {
console.log(href)
await sendEmail(destination.email, destination.givenName, href);
} catch (error) {
console.error(error);
}
},
verify: async (payload, callback) => {
try {
const dbUser = await prisma.user.upsert({
where: {
email: payload.destination,
},
update: {
updatedAt: new Date(Date.now()),
},
create: {
data: {
email: payload.destination,
emailVerified: new Date(Date.now()),
},
},
include: {
employee: {
select: {
userId: true,
isAdmin: true,
},
},
},
});
return callback(null, dbUser);
} catch (error) {
return callback(error);
}
},
});
passport.use(magicLogin);
router.post('/sendlink', magicLogin.send);
router.get('/magiclogin/callback', passport.authenticate('magiclogin'));
The href that is passed to my sendMail function looks like this:
undefined?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXN0aW5hdGlvbiI6eyJlbWFpbCI6ImVyaWMuYnJhbnNvbkBnbWFpbC5jb20iLCJnaXZlbk5hbWUiOiJFcmljIn0sImNvZGUiOiI5OTE4MSIsImlhdCI6MTY3NjA0MzMwOCwiZXhwIjoxNjc2MDQ2OTA4fQ.9vAUmm1pAPIX-tJq8qE3HK-mRY-ZMH7qeJByIqO2RWo
I can remove the undefined but I don't know how it got there in the first place.
This is all in windows 10 in Node 18.12.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels