Skip to content

Commit b1510cc

Browse files
committed
refactor(permissions): reformat codes
1 parent 66ed506 commit b1510cc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/permissions/permissions.service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class PermissionsService {
4141
private readonly dataSource: DataSource,
4242
private readonly userService: UserService,
4343
private readonly resourcesService: ResourcesService,
44-
) { }
44+
) {}
4545

4646
async getGroupPermissions(
4747
namespaceId: string,
@@ -239,7 +239,10 @@ export class PermissionsService {
239239
}
240240
};
241241

242-
const calcGroupPermission = (resource: ResourceMetaDto, groupId: string) => {
242+
const calcGroupPermission = (
243+
resource: ResourceMetaDto,
244+
groupId: string,
245+
) => {
243246
while (true) {
244247
const groupPermission = groupPermissionKeyMap.get(
245248
`${resource.id}||${groupId}`,
@@ -277,16 +280,19 @@ export class PermissionsService {
277280
const permissions: ResourcePermission[] = new Array(resources.length).fill(
278281
ResourcePermission.NO_ACCESS,
279282
);
280-
for (let i = resources.length - 1; i >= 0; i--) {
283+
for (let i = 0; i < resources.length; i++) {
281284
const resource = resources[i];
282285
const userPermission = calcUserPermission(resource);
283286
const groupPermissions = groupIds.map((groupId) =>
284287
calcGroupPermission(resource, groupId),
285288
);
286289
const globalPermission = calcGlobalPermission(resource);
287290
permissions[i] =
288-
maxPermissions([globalPermission, userPermission, ...groupPermissions]) ||
289-
ResourcePermission.NO_ACCESS;
291+
maxPermissions([
292+
globalPermission,
293+
userPermission,
294+
...groupPermissions,
295+
]) || ResourcePermission.NO_ACCESS;
290296
}
291297
return permissions;
292298
}

0 commit comments

Comments
 (0)