Skip to content

Commit

Permalink
[backend] Response status code was updated from 500 to 401 when an Un…
Browse files Browse the repository at this point in the history
…authorized (401) error occurred in OAuth
  • Loading branch information
lim396 committed Mar 4, 2024
1 parent 1de9332 commit 1b927a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export class AuthService {
'Content-Type': 'application/x-www-form-urlencoded',
},
}).then((res) => {
if (res.status === 401) {
throw new UnauthorizedException('Invalid 42 credentials');
}
if (!res.ok) {
return Promise.reject(res.statusText);
}
Expand All @@ -137,6 +140,9 @@ export class AuthService {
Authorization: `Bearer ${access_token}`,
},
}).then((res) => {
if (res.status === 401) {
throw new UnauthorizedException('Invalid 42 credentials');
}
if (!res.ok) {
return Promise.reject(res.statusText);
}
Expand Down

0 comments on commit 1b927a3

Please sign in to comment.