From 83cb62aa52d95d61aedba03b9e455b2f94dcfa61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Garapich?= Date: Sat, 20 Apr 2024 19:56:04 +0200 Subject: [PATCH] fix(auth): log auth error properly (#2823) --- src/auth/controllers/auth.controller.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/auth/controllers/auth.controller.ts b/src/auth/controllers/auth.controller.ts index 0537a8528..74dd361b3 100644 --- a/src/auth/controllers/auth.controller.ts +++ b/src/auth/controllers/auth.controller.ts @@ -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); @@ -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}`); }