Skip to content

Commit 287b4e0

Browse files
committed
Set error response for missing jwt
1 parent 3fe6bb3 commit 287b4e0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/infra/authorization/authorization.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ describe(AuthorizationService.name, () => {
133133
const { req } = setupRequest('roomId', 'other=ABC');
134134
const expectedResult = {
135135
error: {
136-
code: 4500,
137-
reason: 'JWT token not found',
136+
code: 4401,
137+
reason: 'JWT not found',
138138
},
139139
hasWriteAccess: false,
140140
room: null,

src/infra/authorization/authorization.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export class AuthorizationService {
2828

2929
response = await this.fetchAuthorization(room, token);
3030
} catch (error) {
31-
response = this.createErrorResponsePayload(4500, error.message);
31+
if (error.message === 'JWT not found') {
32+
response = this.createErrorResponsePayload(4401, 'JWT not found');
33+
} else {
34+
response = this.createErrorResponsePayload(4500, error.message);
35+
}
3236
}
3337

3438
return response;
@@ -48,7 +52,7 @@ export class AuthorizationService {
4852
const jwtToken = this.getCookie(req, 'jwt');
4953

5054
if (!jwtToken) {
51-
throw new Error('JWT token not found');
55+
throw new Error('JWT not found');
5256
}
5357

5458
return jwtToken;

0 commit comments

Comments
 (0)