Skip to content

Commit

Permalink
[backend] Modify to throw an UnauthorizedException when receiving a 4…
Browse files Browse the repository at this point in the history
…01 Unauthorized response in OAuth (#292)
  • Loading branch information
lim396 authored Mar 4, 2024
1 parent 1de9332 commit ab33f00
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 ab33f00

Please sign in to comment.