fix: Prevent email login token reuse
This commit is contained in:
@@ -91,6 +91,12 @@ export async function getUserForEmailSigninToken(token: string): Promise<User> {
|
|||||||
rejectOnEmpty: true,
|
rejectOnEmpty: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (user.lastSignedInAt) {
|
||||||
|
if (user.lastSignedInAt > new Date(payload.createdAt)) {
|
||||||
|
throw AuthenticationError("Expired token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JWT.verify(token, user.jwtSecret);
|
JWT.verify(token, user.jwtSecret);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user