Fix error when token invalid (#20972)
## Before <img width="914" height="519" alt="image" src="https://github.com/user-attachments/assets/8933bf9e-d8db-4670-ad08-69e900083fc1" /> ## After <img width="1105" height="523" alt="image" src="https://github.com/user-attachments/assets/d8638dbb-adee-4b7d-9d29-1a2a0185ab4f" />
This commit is contained in:
@@ -137,7 +137,10 @@ export class JwtWrapperService {
|
||||
const payload = this.decode<JwtPayload>(token, { json: true });
|
||||
|
||||
if (!isDefined(payload)) {
|
||||
throw new AuthException('No payload', AuthExceptionCode.UNAUTHENTICATED);
|
||||
throw new AuthException(
|
||||
'Token invalid.',
|
||||
AuthExceptionCode.UNAUTHENTICATED,
|
||||
);
|
||||
}
|
||||
|
||||
const { key, algorithm } = await this.resolveVerificationKey(token);
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ describe('Core REST API Authentication', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an Unauthenticated when no token is provided', async () => {
|
||||
it('should return an Unauthenticated when a malformed token is provided', async () => {
|
||||
await makeRestAPIRequest({
|
||||
method: 'post',
|
||||
path: `/people`,
|
||||
@@ -36,7 +36,7 @@ describe('Core REST API Authentication', () => {
|
||||
.expect(401)
|
||||
.expect((res) => {
|
||||
expect(res.body.error).toBe('UNAUTHENTICATED');
|
||||
expect(res.body.messages[0]).toBe('No payload');
|
||||
expect(res.body.messages[0]).toBe('Token invalid.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user