mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: token expire error also should returns anonymous user (#1011)
This commit is contained in:
parent
cf31982127
commit
4cfe996679
1 changed files with 3 additions and 1 deletions
|
@ -198,6 +198,8 @@ export function parseAESCredentials(
|
|||
}
|
||||
}
|
||||
|
||||
export const expireReasons: Array<string> = ['JsonWebTokenError', 'TokenExpiredError'];
|
||||
|
||||
export function verifyJWTPayload(token: string, secret: string): RemoteUser {
|
||||
try {
|
||||
const payload: RemoteUser = (verifyPayload(token, secret): RemoteUser);
|
||||
|
@ -205,7 +207,7 @@ export function verifyJWTPayload(token: string, secret: string): RemoteUser {
|
|||
return payload;
|
||||
} catch (error) {
|
||||
// #168 this check should be removed as soon AES encrypt is removed.
|
||||
if (error.name === 'JsonWebTokenError') {
|
||||
if (expireReasons.includes(error.name)) {
|
||||
// it might be possible the jwt configuration is enabled and
|
||||
// old tokens fails still remains in usage, thus
|
||||
// we return an anonymous user to force log in.
|
||||
|
|
Loading…
Reference in a new issue