Skip to content

Commit

Permalink
Add UI setting for keep_users_without_login
Browse files Browse the repository at this point in the history
Fixes: #118

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Feb 24, 2023
1 parent d7e6160 commit eb3e5d0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/user_retention-main.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/user_retention-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */

/*! For license information please see NcCheckboxRadioSwitch.js.LICENSE.txt */

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/**
Expand Down
2 changes: 1 addition & 1 deletion js/user_retention-main.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function __construct(IConfig $config,
}

public function getForm(): TemplateResponse {
$keepUsersWithoutLogin = (bool) $this->config->getAppValue('user_retention', 'keep_users_without_login', true);
$this->initialStateService->provideInitialState('keep_users_without_login', $keepUsersWithoutLogin);
$userDays = (int) $this->config->getAppValue('user_retention', 'user_days', 0);
$this->initialStateService->provideInitialState('user_days', $userDays);
$guestDays = (int) $this->config->getAppValue('user_retention', 'guest_days', 0);
Expand Down
24 changes: 24 additions & 0 deletions src/views/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
{{ t('user_retention', 'Accounts from LDAP are deleted locally only, unless the LDAP write support app is enabled. When still available on LDAP, accounts will reappear.') }}
</p>

<div>
<label>
<CheckboxRadioSwitch :checked.sync="keepUsersWithoutLogin"
@update:checked="saveKeepUsersWithoutLogin">
{{ t('user_retention', 'Keep accounts that never logged in') }}
</CheckboxRadioSwitch>
</label>
</div>

<div>
<label>
<span>{{ t('user_retention', 'Account expiration:') }}</span>
Expand Down Expand Up @@ -83,6 +92,7 @@
<script>
import axios from '@nextcloud/axios'
import debounce from 'debounce'
import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import Multiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import { generateOcsUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
Expand All @@ -95,6 +105,7 @@ export default {
name: 'AdminSettings',

components: {
CheckboxRadioSwitch,
Multiselect,
},

Expand All @@ -106,6 +117,7 @@ export default {
ldapBackendEnabled: false,
groups: [],
excludedGroups: [],
keepUsersWithoutLogin: true,
userDays: 0,
guestDays: 0,
}
Expand All @@ -114,6 +126,7 @@ export default {
mounted() {
this.loading = true

this.keepUsersWithoutLogin = loadState('user_retention', 'keep_users_without_login')
this.userDays = loadState('user_retention', 'user_days')
this.guestDays = loadState('user_retention', 'guest_days')
this.excludedGroups = loadState('user_retention', 'excluded_groups').sort(function(a, b) {
Expand Down Expand Up @@ -147,6 +160,17 @@ export default {
}
}, 500),

saveKeepUsersWithoutLogin() {
OCP.AppConfig.setValue('user_retention', 'keep_users_without_login', this.keepUsersWithoutLogin, {
success: () => {
showSuccess(t('user_retention', 'Setting saved'))
},
error: () => {
showError(t('user_retention', 'Could not save the setting'))
},
})
},

saveUserDays() {
OCP.AppConfig.setValue('user_retention', 'user_days', this.userDays, {
success: () => {
Expand Down

0 comments on commit eb3e5d0

Please sign in to comment.