Skip to content

Commit

Permalink
other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeppner-dataport committed Dec 10, 2024
1 parent 99a4e9d commit af26650
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ describe(RoomMembershipRule.name, () => {

expect(res).toBe(false);
});

it('should return false for change owner action', () => {
const { user, roomMembershipAuthorizable } = setup();

const res = service.hasPermission(user, roomMembershipAuthorizable, {
action: Action.read,
requiredPermissions: [Permission.ROOM_CHANGE_OWNER],
});

expect(res).toBe(false);
});
});

describe('when user is not member of room', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsMongoId, IsString, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { RoomRole, RoomRoleArray } from '@shared/domain/interface';
import { RoleName, RoomRoleArray } from '@shared/domain/interface';

class UserIdAndRole {
@ApiProperty({
Expand All @@ -17,7 +17,7 @@ class UserIdAndRole {
enum: RoomRoleArray,
})
@IsString()
roleName!: RoomRole;
roleName!: RoleName.ROOMADMIN | RoleName.ROOMEDITOR | RoleName.ROOMVIEWER;
}

export class AddRoomMembersBodyParams {
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/shared/domain/interface/permission.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export enum Permission {
ROOM_EDIT = 'ROOM_EDIT',
ROOM_VIEW = 'ROOM_VIEW',
ROOM_DELETE = 'ROOM_DELETE',
ROOM_MEMBERS_ADD = 'ROOM_MEMBERS_ADD',
ROOM_MEMBERS_REMOVE = 'ROOM_MEMBERS_REMOVE',
ROOM_CHANGE_OWNER = 'ROOM_CHANGE_OWNER',
SCHOOL_CHAT_MANAGE = 'SCHOOL_CHAT_MANAGE',
SCHOOL_CREATE = 'SCHOOL_CREATE',
SCHOOL_EDIT = 'SCHOOL_EDIT',
Expand Down
9 changes: 8 additions & 1 deletion apps/server/src/shared/domain/interface/rolename.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export enum RoleName {
HELPDESK = 'helpdesk',
ROOMVIEWER = 'roomviewer',
ROOMEDITOR = 'roomeditor',
ROOMADMIN = 'roomadmin',
ROOMOWNER = 'roomowner',
STUDENT = 'student',
SUPERHERO = 'superhero',
TEACHER = 'teacher',
Expand All @@ -32,7 +34,12 @@ export type IUserRoleName =
| RoleName.DEMOSTUDENT
| RoleName.DEMOTEACHER;

export const RoomRoleArray = [RoleName.ROOMEDITOR, RoleName.ROOMVIEWER] as const;
export const RoomRoleArray = [
RoleName.ROOMOWNER,
RoleName.ROOMADMIN,
RoleName.ROOMEDITOR,
RoleName.ROOMVIEWER,
] as const;
export type RoomRole = typeof RoomRoleArray[number];

export const GuestRoleArray = [RoleName.GUESTSTUDENT, RoleName.GUESTTEACHER] as const;
Expand Down

0 comments on commit af26650

Please sign in to comment.