chore: update vaults prefs (#2504)
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
SharedVaultListingInterface,
|
||||
VaultListingInterface,
|
||||
KeySystemRootKeyStorageMode,
|
||||
EmojiString,
|
||||
IconType,
|
||||
} from '@standardnotes/models'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SharedVaultServiceEvent, SharedVaultServiceEventPayload } from './SharedVaultServiceEvent'
|
||||
@@ -14,6 +16,7 @@ export interface SharedVaultServiceInterface
|
||||
createSharedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference?: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface | ClientDisplayableError>
|
||||
|
||||
@@ -51,12 +51,12 @@ export class VaultUserService extends AbstractService<VaultUserServiceEvent> imp
|
||||
return result.getValue()
|
||||
}
|
||||
|
||||
public isCurrentUserSharedVaultAdmin(sharedVault: SharedVaultListingInterface): boolean {
|
||||
public isCurrentUserSharedVaultOwner(sharedVault: SharedVaultListingInterface): boolean {
|
||||
return this._isVaultOwner.execute(sharedVault).getValue()
|
||||
}
|
||||
|
||||
async removeUserFromSharedVault(sharedVault: SharedVaultListingInterface, userUuid: string): Promise<Result<void>> {
|
||||
if (!this.isCurrentUserSharedVaultAdmin(sharedVault)) {
|
||||
if (!this.isCurrentUserSharedVaultOwner(sharedVault)) {
|
||||
throw new Error('Only vault admins can remove users')
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface VaultUserServiceInterface extends ApplicationServiceInterface<VaultUserServiceEvent, unknown> {
|
||||
getSharedVaultUsers(sharedVault: SharedVaultListingInterface): Promise<SharedVaultUserServerHash[] | undefined>
|
||||
isCurrentUserSharedVaultAdmin(sharedVault: SharedVaultListingInterface): boolean
|
||||
isCurrentUserSharedVaultOwner(sharedVault: SharedVaultListingInterface): boolean
|
||||
removeUserFromSharedVault(sharedVault: SharedVaultListingInterface, userUuid: string): Promise<Result<void>>
|
||||
leaveSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void>
|
||||
isVaultUserOwner(user: SharedVaultUserServerHash): boolean
|
||||
|
||||
Reference in New Issue
Block a user