Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IoT-1592 - Feedback #272

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/services/device-management/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ export class ApplicationService {
});
const app = await this.applicationRepository.save(mappedApplication);

await this.permissionService.autoAddPermissionsToApplication(app);

return app;
} catch (e) {
throw new BadRequestException(ErrorCodes.InvalidPost);
Expand Down
25 changes: 0 additions & 25 deletions src/services/user-management/permission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,6 @@ export class PermissionService {
return await this.permissionRepository.save(permission);
}

async autoAddPermissionsToApplication(app: Application): Promise<void> {
// Use query builder since the other syntax doesn't support one-to-many for property querying
const permissionsInOrganisation = await this.permissionRepository
.createQueryBuilder("permission")
.where(
"permission.organization.id = :orgId" +
" AND type.type IN (:...permType)" +
` AND "${nameof<Permission>("automaticallyAddNewApplications")}" = True`,
{
orgId: app.belongsTo.id,
permType: [PermissionType.OrganizationApplicationAdmin, PermissionType.Read],
}
)
.leftJoinAndSelect("permission.applications", "app")
.leftJoin("permission.type", "type")
.getMany();

await Promise.all(
permissionsInOrganisation.map(async p => {
p.applications.push(app);
await this.permissionRepository.save(p);
})
);
}

async addUsersToPermission(permission: Permission, users: User[]): Promise<void> {
users.forEach(x => {
x.permissions = _.union(x.permissions, [permission]);
Expand Down
Loading