mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05:00
fix: don't create user permissions for owner
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
825b3b72ff
commit
e02221acd2
2 changed files with 10 additions and 0 deletions
|
@ -1015,6 +1015,13 @@ describe('PermissionsService', () => {
|
|||
expect(eventEmitterEmitSpy).toHaveBeenCalled();
|
||||
});
|
||||
describe('works', () => {
|
||||
it('with user not added if owner', async () => {
|
||||
const user = User.create('test', 'Testy') as User;
|
||||
const note = Note.create(user) as Note;
|
||||
const resultNote = await service.setUserPermission(note, user, true);
|
||||
expect(await resultNote.userPermissions).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('with user not added before and editable', async () => {
|
||||
const note = Note.create(null) as Note;
|
||||
const user = User.create('test', 'Testy') as User;
|
||||
|
|
|
@ -235,6 +235,9 @@ export class PermissionsService {
|
|||
permissionUser: User,
|
||||
canEdit: boolean,
|
||||
): Promise<Note> {
|
||||
if (await this.isOwner(permissionUser, note)) {
|
||||
return note;
|
||||
}
|
||||
const permissions = await note.userPermissions;
|
||||
const permission = await this.findPermissionForUser(
|
||||
permissions,
|
||||
|
|
Loading…
Reference in a new issue