Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/d-rec/drec-origin into D…
Browse files Browse the repository at this point in the history
…R-839_Update_User_Fix
  • Loading branch information
Aish1990 committed Jul 8, 2024
2 parents aa90551 + a7611d2 commit c01cd53
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/drec-api/src/pods/device/device.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,12 @@ export class DeviceController {
): Promise<DeviceDTO | null> {
this.logger.verbose(`With in getByExternalId`);
let devicedata: Device;
if (loginUser.role === Role.ApiUser) {

if (loginUser.role === Role.ApiUser || loginUser.role === Role.Admin) {
if (loginUser.role === Role.Admin) {
loginUser.api_user_id = null;
}

devicedata =
await this.deviceService.findDeviceByDeveloperExternalIByApiUser(
id,
Expand Down Expand Up @@ -633,12 +638,14 @@ export class DeviceController {
user.organizationId = deviceToUpdate.organizationId;
}
} else {
if (user.organizationId != org.id) {
if (user.role != Role.Admin && user.organizationId != org.id) {
this.logger.error(`Unauthorized`);
throw new UnauthorizedException({
success: false,
message: 'Unauthorized',
});
} else if (user.role === Role.Admin) {
user.organizationId = deviceToUpdate.organizationId;
}
}
}
Expand Down

0 comments on commit c01cd53

Please sign in to comment.