migration to postgres
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,16 +46,16 @@ export const userMiddleware: MiddlewareHandler = async function (ctx, next) {
|
||||
|
||||
// Check if token is blacklisted (explicit signout)
|
||||
if (user.jti) {
|
||||
if (isTokenBlacklisted(user.jti)) throw errors.UNAUTHORIZED();
|
||||
if (await isTokenBlacklisted(user.jti)) throw errors.UNAUTHORIZED();
|
||||
}
|
||||
|
||||
// Check if token was issued before password change
|
||||
if (user.iat && user.id) {
|
||||
const dbUser = getUserById(user.id);
|
||||
const dbUser = await getUserById(user.id);
|
||||
if (dbUser?.passwordChangedAt) {
|
||||
// iat is in seconds, passwordChangedAt is in milliseconds
|
||||
// iat is in seconds, passwordChangedAt is a Date
|
||||
const tokenIssuedAt = user.iat * 1000;
|
||||
if (tokenIssuedAt < dbUser.passwordChangedAt) {
|
||||
if (tokenIssuedAt < dbUser.passwordChangedAt.getTime()) {
|
||||
throw errors.UNAUTHORIZED();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user