Skip to content

Commit

Permalink
Consider admin defaults when creating shares
Browse files Browse the repository at this point in the history
The current share logic always uses the default `BUNDLED_PERMISSIONS.ALL`
which includes everything.

This commit updates share creation logic to use `defaultPermissions` if set
by admin for the creation of new shares.

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Jan 22, 2024
1 parent 93db067 commit 502d6c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/files_sharing/lib/Listener/LoadSidebarListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function handle(Event $event): void {

$shareConfig = [
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
'defaultPermissions' => $this->shareManager->shareApiDefaultPermissions()
];

$this->initialState->provideInitialState('shareConfig', $shareConfig);
Expand Down
11 changes: 11 additions & 0 deletions apps/files_sharing/src/services/ConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ export default class Config {
this._shareConfig = loadState('files_sharing', 'shareConfig', {})
}

/**
* Get default share permissions, if any
*
* @return {boolean}
* @readonly
* @memberof Config
*/
get defaultPermissions() {
return this._shareConfig.defaultPermissions
}

/**
* Is public upload allowed on link shares ?
*
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Share/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ public function newShare();
*/
public function shareApiEnabled();

/**
* Get default share permissions set by admin
*
* @return int
* @since 9.0.0
*/
public function shareApidefaultPermissions(): int;

/**
* Is public link sharing enabled
*
Expand Down

0 comments on commit 502d6c6

Please sign in to comment.