From 9db99b4e2ecd8ba4d165a7e6321c15b38ad45084 Mon Sep 17 00:00:00 2001 From: Kar Rui Lau Date: Thu, 3 Sep 2020 11:42:52 +0800 Subject: [PATCH] refactor(AuthController): update error type check to ApplicationError --- src/app/modules/auth/auth.controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/modules/auth/auth.controller.ts b/src/app/modules/auth/auth.controller.ts index 278c558468..c32198f68a 100644 --- a/src/app/modules/auth/auth.controller.ts +++ b/src/app/modules/auth/auth.controller.ts @@ -7,9 +7,9 @@ import defaults from '../../../config/defaults' import { createLoggerWithLabel } from '../../../config/logger' import MailService from '../../services/mail.service' import { getRequestIp } from '../../utils/request' +import { ApplicationError } from '../core/core.errors' import * as UserService from '../user/user.service' -import { InvalidOtpError } from './auth.errors' import * as AuthService from './auth.service' const logger = createLoggerWithLabel(module) @@ -108,14 +108,14 @@ export const handleLoginVerifyOtp: RequestHandler< if (verifyErr) { logger.warn({ message: - verifyErr instanceof InvalidOtpError + verifyErr instanceof ApplicationError ? 'Login OTP is invalid' : 'Error occurred when trying to validate login OTP', meta: logMeta, error: verifyErr, }) - if (verifyErr instanceof InvalidOtpError) { + if (verifyErr instanceof ApplicationError) { return res.status(verifyErr.status).send(verifyErr.message) }