fix(auth): return rooms on login

This commit is contained in:
avicenan
2026-06-05 15:16:25 +09:00
parent 89e4db9b87
commit a783b94561
2 changed files with 15 additions and 9 deletions

View File

@ -115,6 +115,12 @@ export class AuthController {
hrms.level_name = user.employee.position?.name || null
}
const query = `SELECT r.id, r.room, r.code
FROM rooms r
INNER JOIN user_to_room utr ON utr.room_id = r.id
WHERE utr.user_id = $1 AND r.deleted_at IS NULL AND utr.deleted_at IS NULL`
const rooms = await OrmHelper.DB.query(query, [user.id])
var privateKey = fs.readFileSync("src/helpers/key/private.key")
var token = jwt.sign(
@ -127,6 +133,7 @@ export class AuthController {
id_role: role_id,
roles: roles.roles,
hrms: hrms,
rooms: rooms,
},
},
privateKey,
@ -136,7 +143,7 @@ export class AuthController {
delete user.password
const data = {
user: { ...user, ...hrms },
user: { ...user, ...hrms, rooms },
role_name: roles.name,
roles_list: await AuthController.getListRole(roles.roles),
token: {