Skip to content

Commit

Permalink
fix redirect frontend url
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneleon1 committed Jul 3, 2024
1 parent 60a10d5 commit 47ebdf8
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/routes/auth-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ authRoutes.get(
twoFactorCode: twoFactorCode.toString(),
});
}
return res.status(200).json({
message: 'Please provide the 2FA code sent to your email.',
user: { id: user.id, email: user.email },
});
return res.redirect(
`${process.env.FRONTEND_URL}/verify-2fa/${user.id}/${user.email}`
);
}

const token = jwt.sign({ user }, process.env.JWT_SECRET as jwt.Secret, {
expiresIn: '7d',
});

return res.json({
token: token,
});
return res.redirect(`${process.env.FRONTEND_URL}/signIn?token=${token}`);
}
);

Expand All @@ -68,19 +65,16 @@ authRoutes.get(
twoFactorCode: twoFactorCode.toString(),
});
}
return res.status(200).json({
message: 'Please provide the 2FA code sent to your email.',
user: { id: user.id, email: user.email },
});
return res.redirect(
`${process.env.FRONTEND_URL}/verify-2fa/${user.id}/${user.email}`
);
}

const token = jwt.sign({ user }, process.env.JWT_SECRET as jwt.Secret, {
expiresIn: '7d',
});

return res.json({
token: token,
});
return res.redirect(`${process.env.FRONTEND_URL}/signIn?token=${token}`);
}
);

Expand Down

0 comments on commit 47ebdf8

Please sign in to comment.