fix(auth): error login on user or password is incorrect

This commit is contained in:
avicenan
2026-04-15 10:20:23 +07:00
parent 6a0fa980bd
commit 567089c03d
2 changed files with 74 additions and 70 deletions

View File

@ -52,6 +52,10 @@ export class AuthController {
where: { username: param.username },
})
if (!user) {
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)) {
const { browser, device, os } = UAParser(req.get("User-Agent"))
@ -146,9 +150,9 @@ export class AuthController {
}
if (user.roles == null || user.roles.length == 0) {
return ReturnHelper.errorResponse(res, 403, 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 {
return ReturnHelper.errorResponse(res, 403, 402, Language.lang.failed_access)
return ReturnHelper.errorResponse(res, 401, 401, Language.lang.failed_access + ", username or password is incorrect")
}
} catch (e: unknown) {
log.error(e)

View File

@ -18,7 +18,7 @@ const doc = {
login: {
$username: "admin",
$password: "12345aA!",
$application: "hrms",
$application: "saude",
},
user: {
$employee_id: "EMP001",