Skip to content

Commit

Permalink
fix(auth): log auth error properly (#2823)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Apr 20, 2024
1 parent 4d714c8 commit 83cb62a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/auth/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AuthController {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
return passport.authenticate(
'steam',
(error: Error, player: Player) => {
(error: unknown, player: Player) => {
let url = this.environment.clientUrl;
if (req.headers.cookie) {
const cookies = parse(req.headers.cookie);
Expand All @@ -49,7 +49,14 @@ export class AuthController {
}

if (error) {
this.logger.warn(`Login error: ${error.message}`);
if (error instanceof Error) {
this.logger.warn(`Login error: ${error.message}`);
} else if (typeof error === 'string') {
this.logger.warn(`Login error: ${error}`);
} else {
this.logger.warn(`Login error: ${JSON.stringify(error)}`);
}

const clientErrorCode = this.mapToClientError(error);
return res.redirect(`${url}/auth-error?error=${clientErrorCode}`);
}
Expand Down

0 comments on commit 83cb62a

Please sign in to comment.