fix(auth): throw error on login

This commit is contained in:
avicenan
2026-04-15 11:30:23 +07:00
parent 567089c03d
commit 32a7fe219e

View File

@ -53,7 +53,7 @@ export class AuthController {
}) })
if (!user) { if (!user) {
return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access + ", username or password is incorrect") return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access, "Username or password is incorrect")
} }
if (user != null && user.roles != null && user.roles.length > 0 && user.checkIfPasswordMatch(param.password)) { if (user != null && user.roles != null && user.roles.length > 0 && user.checkIfPasswordMatch(param.password)) {
@ -86,7 +86,7 @@ export class AuthController {
} }
if (role_id == "") { if (role_id == "") {
return ReturnHelper.errorResponse(res, 403, 403, Language.lang.failed_access + ", you don't have any roles in this application") return ReturnHelper.errorResponse(res, 403, 403, Language.lang.failed_access, "You don't have any roles in this application")
} else { } else {
// const userRole = await userRoleRepository.findOneBy({ id: role_id }) // const userRole = await userRoleRepository.findOneBy({ id: role_id })
var hrms = { var hrms = {
@ -150,9 +150,9 @@ export class AuthController {
} }
if (user.roles == null || user.roles.length == 0) { if (user.roles == null || user.roles.length == 0) {
return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access + ", you don't have any roles in this application") return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access, "You don't have any roles in this application")
} else { } else {
return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access + ", username or password is incorrect") return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access, "Username or password is incorrect")
} }
} catch (e: unknown) { } catch (e: unknown) {
log.error(e) log.error(e)