fix: improper 500 in wisp token verify

This commit is contained in:
KernelDeimos 2025-01-10 10:27:22 -05:00
parent 7aa886d573
commit 75aaaa66a8

View File

@ -57,10 +57,17 @@ class WispService extends BaseService {
const svc_apiError = this.services.get('api-error');
const svc_event = this.services.get('event');
const decoded = svc_token.verify('wisp', req.body.token);
if ( decoded.$ !== 'token:wisp' ) {
throw svc_apiError.create('invalid_token');
}
const decoded = (() => {
try {
const decoded = svc_token.verify('wisp', req.body.token);
if ( decoded.$ !== 'token:wisp' ) {
throw svc_apiError.create('invalid_token');
}
return decoded;
} catch (e) {
throw svc_apiError.create('forbidden');
}
})();
const svc_getUser = this.services.get('get-user');