mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 18:01:59 +00:00
fix: handle token errors in front service (#8336)
This commit is contained in:
parent
edda71fef4
commit
b84d839a01
@ -525,6 +525,10 @@ export function start (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
if (error instanceof TokenError) {
|
||||||
|
res.status(401).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
error?.code === 'NoSuchKey' ||
|
error?.code === 'NoSuchKey' ||
|
||||||
error?.code === 'NotFound' ||
|
error?.code === 'NotFound' ||
|
||||||
@ -633,6 +637,10 @@ export function start (
|
|||||||
|
|
||||||
res.status(200).send()
|
res.status(200).send()
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
if (error instanceof TokenError) {
|
||||||
|
res.status(401).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
Analytics.handleError(error)
|
Analytics.handleError(error)
|
||||||
ctx.error('failed to delete', { url: req.url })
|
ctx.error('failed to delete', { url: req.url })
|
||||||
res.status(500).send()
|
res.status(500).send()
|
||||||
|
@ -45,7 +45,11 @@ export function generateToken (
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function decodeToken (token: string, verify: boolean = true, secret?: string): Token {
|
export function decodeToken (token: string, verify: boolean = true, secret?: string): Token {
|
||||||
return decode(token, secret ?? getSecret(), !verify)
|
try {
|
||||||
|
return decode(token, secret ?? getSecret(), !verify)
|
||||||
|
} catch (err: any) {
|
||||||
|
throw new TokenError(err.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user