mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
refactor(server): prevent sharing album with owner by filtering out user from albumUsers (#28891)
fix(server): prevent sharing album with owner by filtering out user from albumUsers
This commit is contained in:
parent
9e453440e6
commit
474efd39f8
3 changed files with 24 additions and 19 deletions
|
|
@ -504,13 +504,14 @@ describe('/albums', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not be able to share album with owner', async () => {
|
||||
it('should deduplicate owner from albumUsers on create', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.post('/albums')
|
||||
.send({ albumName: 'New album', albumUsers: [{ role: AlbumUserRole.Editor, userId: user1.userId }] })
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest('Cannot share album with owner'));
|
||||
expect(status).toBe(201);
|
||||
expect(body.albumUsers).toHaveLength(1);
|
||||
expect(body.albumUsers[0]).toMatchObject({ role: AlbumUserRole.Owner, user: { id: user1.userId } });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue