fix: invalid token expire time
This commit is contained in:
		
							parent
							
								
									f338736775
								
							
						
					
					
						commit
						4443e80b6f
					
				
					 1 changed files with 2 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue