fixed remove permission if role STAFF
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s

This commit is contained in:
Warunee Tamkoo 2026-07-17 21:21:37 +07:00
parent 26732420c2
commit c356a06899

View file

@ -73,7 +73,6 @@ export class KeycloakController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
private posMasterRepository = AppDataSource.getRepository(PosMaster);
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
private roleKeycloakRepo = AppDataSource.getRepository(RoleKeycloak);
@Get("user/{id}")
@ -387,12 +386,16 @@ export class KeycloakController extends Controller {
);
if (!result) throw new Error("Failed. Cannot remove user's role.");
if (profileId) {
// delete authRoleId in posMaster if roleId is "f1fff8db-0795-47c1-9952-f3c18d5b6172"
if (profileId && roleId === "f1fff8db-0795-47c1-9952-f3c18d5b6172") {
let _null: any = null;
const authRoleId = _null;
console.log(`Clearing authRoleId on position records for profile ${profileId}`);
try {
await this.posMasterRepository
.createQueryBuilder()
.update(PosMaster)
.set({ authRoleId: '' })
.set({ authRoleId: authRoleId })
.where("current_holderId = :profileId", { profileId })
.execute();
} catch (error) {