mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36: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();
|
expect(eventEmitterEmitSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
describe('works', () => {
|
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 () => {
|
it('with user not added before and editable', async () => {
|
||||||
const note = Note.create(null) as Note;
|
const note = Note.create(null) as Note;
|
||||||
const user = User.create('test', 'Testy') as User;
|
const user = User.create('test', 'Testy') as User;
|
||||||
|
|
|
@ -235,6 +235,9 @@ export class PermissionsService {
|
||||||
permissionUser: User,
|
permissionUser: User,
|
||||||
canEdit: boolean,
|
canEdit: boolean,
|
||||||
): Promise<Note> {
|
): Promise<Note> {
|
||||||
|
if (await this.isOwner(permissionUser, note)) {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
const permissions = await note.userPermissions;
|
const permissions = await note.userPermissions;
|
||||||
const permission = await this.findPermissionForUser(
|
const permission = await this.findPermissionForUser(
|
||||||
permissions,
|
permissions,
|
||||||
|
|
Loading…
Reference in a new issue