Skip to content

Commit

Permalink
refs #21045 avoid getting/setting/displaying unlimited default quota …
Browse files Browse the repository at this point in the history
…if not allowed

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Jul 19, 2021
1 parent 8cd57de commit d2cf158
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 115 deletions.
7 changes: 7 additions & 0 deletions apps/provisioning_api/lib/Controller/AppConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,12 @@ protected function verifyConfigKey(string $app, string $key, string $value) {
if ($app === 'core' && (strpos($key, 'public_') === 0 || strpos($key, 'remote_') === 0)) {
throw new \InvalidArgumentException('The given key can not be set');
}

if ($app === 'files'
&& $key === 'default_quota'
&& $value === 'none'
&& $this->config->getAppValue('files', 'allow_unlimited_quota', '1') === '0') {
throw new \InvalidArgumentException('The given key can not be set, unlimited quota is forbidden on this instance');
}
}
}
4 changes: 2 additions & 2 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
} else {
$maxQuota = (int) $this->config->getAppValue('files', 'max_quota', '-1');
if ($maxQuota !== -1 && $quota > $maxQuota) {
throw new OCSException('Invalid quota value '.$value, 102);
throw new OCSException('Invalid quota value. ' . $value . ' is exceeding the maximum quota', 102);
}
$quota = \OCP\Util::humanFileSize($quota);
}
Expand All @@ -809,7 +809,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
if ($quota === 'none') {
$allowUnlimitedQuota = $this->config->getAppValue('files', 'allow_unlimited_quota', '1') === '1';
if (!$allowUnlimitedQuota) {
throw new OCSException('Invalid quota value '.$value, 102);
throw new OCSException('Unlimited quota is forbidden on this instance', 102);
}
}
$targetUser->setQuota($quota);
Expand Down
35 changes: 17 additions & 18 deletions apps/settings/js/vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-admin-security.js.map

Large diffs are not rendered by default.

157 changes: 149 additions & 8 deletions apps/settings/js/vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions apps/settings/js/vue-settings-nextcloud-pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-nextcloud-pdf.js.map

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions apps/settings/js/vue-settings-personal-info.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-info.js.map

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions apps/settings/js/vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-security.js.map

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions apps/settings/js/vue-settings-personal-webauthn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-webauthn.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion apps/settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ export default {
// convert the preset array into objects
const quotaPreset = this.settings.quotaPreset.reduce((acc, cur) => acc.concat({ id: cur, label: cur }), [])
// add default presets
quotaPreset.unshift(this.unlimitedQuota)
if (this.settings.allowUnlimitedQuota) {
quotaPreset.unshift(this.unlimitedQuota)
}
return quotaPreset
},
// mapping saved values to objects
Expand Down

0 comments on commit d2cf158

Please sign in to comment.