diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index b5add4be..c4b37b33 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -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) {