Update token generation (#1372)

- Permit only decode token to get map details,
 - If user have token expired, set the token to null and reload the page. This feature will be updated when authentication stategy will be finished.

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
grégoire parant 2021-08-15 22:51:06 +02:00 committed by GitHub
parent 02a21209ec
commit 8d57886bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View file

@ -15,9 +15,9 @@ class JWTTokenManager {
return Jwt.sign({ identifier }, SECRET_KEY, { expiresIn: "200d" });
}
public decodeJWTToken(token: string): AuthTokenData {
public verifyJWTToken(token: string, ignoreExpiration: boolean = false): AuthTokenData {
try {
return Jwt.verify(token, SECRET_KEY, { ignoreExpiration: false }) as AuthTokenData;
return Jwt.verify(token, SECRET_KEY, { ignoreExpiration }) as AuthTokenData;
} catch (e) {
throw { reason: tokenInvalidException, message: e.message };
}