Skip to content

Commit 416aec0

Browse files
fix(admin-delegation): display delegated section in common settings for non-admin
IDeclarativeSettingsForm can't be delegated and can be shown only to admin. Lets not load IDeclarativeSettings for non admins. Otherwise we get "Access forbidden" while displaying /settings/admin and prevent to show delegated sections to non admin like: Background jobs OCA\Settings\Settings\Admin\Server Email server OCA\Settings\Settings\Admin\Mail Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent ff07c99 commit 416aec0

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

apps/settings/lib/Controller/CommonSettingsTrait.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,17 @@ private function getIndexResponse(string $type, string $section): TemplateRespon
136136
$user = $this->userSession->getUser();
137137
assert($user !== null, 'No user logged in for settings');
138138

139-
$this->declarativeSettingsManager->loadSchemas();
140-
$declarativeSettings = $this->declarativeSettingsManager->getFormsWithValues($user, $type, $section);
139+
$declarativeSettings = [];
141140

142-
foreach ($declarativeSettings as &$form) {
143-
foreach ($form['fields'] as &$field) {
144-
if (isset($field['sensitive']) && $field['sensitive'] === true && !empty($field['value'])) {
145-
$field['value'] = 'dummySecret';
141+
if ($type !== 'admin' || $this->groupManager->isAdmin($user->getUID())) {
142+
$this->declarativeSettingsManager->loadSchemas();
143+
$declarativeSettings = $this->declarativeSettingsManager->getFormsWithValues($user, $type, $section);
144+
145+
foreach ($declarativeSettings as &$form) {
146+
foreach ($form['fields'] as &$field) {
147+
if (isset($field['sensitive']) && $field['sensitive'] === true && !empty($field['value'])) {
148+
$field['value'] = 'dummySecret';
149+
}
146150
}
147151
}
148152
}

0 commit comments

Comments
 (0)