mirror of
https://github.com/standardnotes/server
synced 2026-10-12 15:13:39 -04:00
fix(syncing-server): force remove shared vault owner when removing shared vault
This commit is contained in:
+20
@@ -102,6 +102,26 @@ describe('RemoveUserFromSharedVault', () => {
|
||||
expect(result.getError()).toBe('Only owner can remove users from shared vault')
|
||||
})
|
||||
|
||||
it('should remove shared vault user if user is owner and is being force removed', async () => {
|
||||
sharedVault = SharedVault.create({
|
||||
fileUploadBytesLimit: 100,
|
||||
fileUploadBytesUsed: 2,
|
||||
userUuid: Uuid.create('00000000-0000-0000-0000-000000000002').getValue(),
|
||||
timestamps: Timestamps.create(123, 123).getValue(),
|
||||
}).getValue()
|
||||
sharedVaultRepository.findByUuid = jest.fn().mockResolvedValue(sharedVault)
|
||||
|
||||
const useCase = createUseCase()
|
||||
await useCase.execute({
|
||||
originatorUuid: '00000000-0000-0000-0000-000000000002',
|
||||
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
|
||||
userUuid: '00000000-0000-0000-0000-000000000001',
|
||||
forceRemoveOwner: true,
|
||||
})
|
||||
|
||||
expect(sharedVaultUserRepository.remove).toHaveBeenCalledWith(sharedVaultUser)
|
||||
})
|
||||
|
||||
it('should return error when user is owner of shared vault', async () => {
|
||||
const useCase = createUseCase()
|
||||
const result = await useCase.execute({
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ export class RemoveUserFromSharedVault implements UseCaseInterface<void> {
|
||||
}
|
||||
|
||||
const removingOwner = sharedVault.props.userUuid.equals(userUuid)
|
||||
if (removingOwner) {
|
||||
if (removingOwner && !dto.forceRemoveOwner) {
|
||||
return Result.fail('Owner cannot be removed from shared vault')
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -2,4 +2,5 @@ export interface RemoveUserFromSharedVaultDTO {
|
||||
sharedVaultUuid: string
|
||||
originatorUuid: string
|
||||
userUuid: string
|
||||
forceRemoveOwner?: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user