fix: invalid token expire time

This commit is contained in:
monoid 2022-05-03 14:04:49 +09:00
parent f338736775
commit 4443e80b6f

View File

@ -84,11 +84,11 @@ const setToken = (
httpOnly: true,
secure: !setting.localmode,
sameSite: "strict",
expires: new Date(Date.now() + expiredtime),
expires: new Date(Date.now() + expiredtime * 1000),
});
};
export const createLoginMiddleware = (userController: UserAccessor) =>
async (ctx: Koa.Context, next: Koa.Next) => {
async (ctx: Koa.Context, _next: Koa.Next) => {
const setting = get_setting();
const secretKey = setting.jwt_secretkey;
const body = ctx.request.body;
@ -190,7 +190,6 @@ const refreshTokenHandler = (cntr: UserAccessor) =>
} else {
console.error("invalid token detected");
throw new Error("token form invalid");
return;
}
} catch (e) {
if (e instanceof TokenExpiredError) { // refresh token is expired.