File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,9 +14,8 @@ import { config } from "./config";
1414
1515export class Token {
1616 private secret : string | undefined ;
17- private accessExp : number = Math . floor ( Date . now ( ) / 1000 ) + 60 * 60 ; // 1h;
18- private refreshExp : number =
19- Math . floor ( Date . now ( ) / 1000 ) + 60 * 60 * 24 * 30 * 3 ; // 3 months
17+ private accessExp : number = 60 * 60 ; // 1h;
18+ private refreshExp : number = 60 * 60 * 24 * 30 * 3 ; // 3 months
2019
2120 constructor ( secret ?: string , accessExp ?: number , refreshExp ?: number ) {
2221 secret && ( this . secret = secret ) ;
@@ -48,9 +47,10 @@ export class Token {
4847 if ( ! this . secret ) {
4948 throw new Error ( "密匙不可为空" ) ;
5049 }
50+ let exp : number = Math . floor ( Date . now ( ) / 1000 ) + this . accessExp ;
5151 return jwtGenerator . sign (
5252 {
53- exp : this . accessExp ,
53+ exp : exp ,
5454 identity : identity ,
5555 type : TokenType . ACCESS
5656 } ,
@@ -66,9 +66,10 @@ export class Token {
6666 if ( ! this . secret ) {
6767 throw new Error ( "密匙不可为空" ) ;
6868 }
69+ let exp : number = Math . floor ( Date . now ( ) / 1000 ) + this . refreshExp ;
6970 return jwtGenerator . sign (
7071 {
71- exp : this . refreshExp ,
72+ exp : exp ,
7273 identity : identity ,
7374 type : TokenType . REFRESH
7475 } ,
Original file line number Diff line number Diff line change 11{
22 "name" : " lin-cms" ,
3- "version" : " 0.0.1-alpha5 " ,
3+ "version" : " 0.0.1-alpha6 " ,
44 "description" : " The core library of Lin CMS, this package is just for test!" ,
55 "main" : " lin/index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments