File tree 1 file changed +13
-1
lines changed
projects/fusio-sdk/src/lib/service 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export abstract class FusioService<T extends ClientAbstract> {
64
64
}
65
65
66
66
const unixTimestamp = Math . floor ( Date . now ( ) / 1000 ) ;
67
- return token . expires_in > unixTimestamp ;
67
+ return this . getExpiresInTimestamp ( token . expires_in ) > unixTimestamp ;
68
68
}
69
69
70
70
public logout ( ) : void {
@@ -90,4 +90,16 @@ export abstract class FusioService<T extends ClientAbstract> {
90
90
}
91
91
}
92
92
93
+ private getExpiresInTimestamp ( expiresIn : number ) : number
94
+ {
95
+ const nowTimestamp = Math . floor ( Date . now ( ) / 1000 ) ;
96
+
97
+ if ( expiresIn < 529196400 ) {
98
+ // in case the expires in is lower than 1986-10-09 we assume that the field represents the duration in seconds
99
+ // otherwise it is probably a timestamp
100
+ expiresIn = nowTimestamp + expiresIn ;
101
+ }
102
+
103
+ return expiresIn ;
104
+ }
93
105
}
You can’t perform that action at this time.
0 commit comments