-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add roomadmin and roomowner roles * remove room_delete permission from roomeditor * creating room memberships is now an operation seperate from adding users. ** creating a room memberships adds a user as owner ** adding a user fails if no membership exists yet * fix room membership rule to use room role to check permissions * ensure that room owners can not be removed from a room --------- Co-authored-by: Thomas Feldtkeller <[email protected]>
- Loading branch information
1 parent
9737e90
commit 0df7b67
Showing
18 changed files
with
429 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
apps/server/src/migrations/mikro-orm/Migration20241209165812.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
export class Migration20241209165812 extends Migration { | ||
async up(): Promise<void> { | ||
// Add ROOM_OWNER role | ||
await this.getCollection('roles').insertOne({ | ||
name: 'roomowner', | ||
permissions: [ | ||
'ROOM_VIEW', | ||
'ROOM_EDIT', | ||
'ROOM_DELETE', | ||
'ROOM_MEMBERS_ADD', | ||
'ROOM_MEMBERS_REMOVE', | ||
'ROOM_CHANGE_OWNER', | ||
], | ||
}); | ||
console.info( | ||
'Added ROOM_OWNER role with ROOM_VIEW, -_EDIT, _DELETE, -_MEMBERS_ADD, -_MEMBERS_REMOVE AND -_CHANGE_OWNER permission' | ||
); | ||
|
||
// Add ROOM_ADMIN role | ||
await this.getCollection('roles').insertOne({ | ||
name: 'roomadmin', | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_MEMBERS_ADD', 'ROOM_MEMBERS_REMOVE'], | ||
}); | ||
console.info( | ||
'Added ROOM_ADMIN role with ROOM_VIEW, ROOM_EDIT, ROOM_MEMBERS_ADD AND ROOM_MEMBERS_REMOVE permissions' | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
// Remove ROOM_OWNER role | ||
await this.getCollection('roles').deleteOne({ name: 'roomowner' }); | ||
console.info('Rollback: Removed ROOM_OWNER role'); | ||
|
||
// Remove ROOM_ADMIN role | ||
await this.getCollection('roles').deleteOne({ name: 'roomadmin' }); | ||
console.info('Rollback: Removed ROOM_ADMIN role'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/server/src/migrations/mikro-orm/Migration20241210152600.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
export class Migration20241210152600 extends Migration { | ||
async up(): Promise<void> { | ||
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne( | ||
{ name: 'roomeditor' }, | ||
{ | ||
$set: { | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT'], | ||
}, | ||
} | ||
); | ||
|
||
if (roomEditorRoleUpdate.modifiedCount > 0) { | ||
console.info('Permission ROOM_DELETE removed from role roomeditor.'); | ||
} | ||
} | ||
|
||
async down(): Promise<void> { | ||
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne( | ||
{ name: 'roomeditor' }, | ||
{ | ||
$set: { | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_DELETE'], | ||
}, | ||
} | ||
); | ||
|
||
if (roomEditorRoleUpdate.modifiedCount > 0) { | ||
console.info( | ||
'Rollback: Permissions ROOM_DELETE added to and ROOM_MEMBERS_ADD and ROOM_MEMBERS_REMOVE removed from role roomeditor.' | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.