FIX: unitary permitting

This commit is contained in:
Victor Radael
2022-10-04 13:20:34 -03:00
parent 2b03c4e4a9
commit 63fbfa6b52
2 changed files with 23 additions and 3 deletions
+22 -2
View File
@@ -222,7 +222,11 @@ export class CatalogController {
user: user.user_id,
customer: user.customer_name,
});
const { user_id, customer_name, customer_id } = user;
const { user_id, customer_name, customer_id, permissions } = user;
const is_data_manager = permissions.includes(
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER.seqid,
);
let has_permission = false;
const metadata = PackTheMetadata({
user_id,
customer_id,
@@ -233,13 +237,29 @@ export class CatalogController {
const res = await this.catalogService.getAllTableMetadata(body);
return res;
} else {
const user_roles = await this.catalogService.getUserRolesIds(user_id);
const res = await this.catalogService.getOneTableMetadata(
body,
query,
metadata,
customer_id,
);
return res;
const table = res[0];
for (const role of user_roles) {
if (table.roles.includes(role)) has_permission = true;
}
if (table.users.includes(user_id)) has_permission = true;
if (is_data_manager || has_permission) {
return res;
}
throw new HttpException(
'You do not have permission to access this data asset.',
403,
);
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long