aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2023-12-06 10:44:51 +0100
committerGitHub <noreply@github.com>2023-12-06 10:44:51 +0100
commitb10f72fcccc7cdcd465f140d27f9946854de4b42 (patch)
treed9dac80ffe26541e57121c7d857bb5b40c0aa059 /apps
parent675d25e86545db960dc258f530cb837eaf88e908 (diff)
parenta9d86c1f95a013d37be90a1974545b377de0c7e7 (diff)
downloadnextcloud-server-b10f72fcccc7cdcd465f140d27f9946854de4b42.tar.gz
nextcloud-server-b10f72fcccc7cdcd465f140d27f9946854de4b42.zip
Merge pull request #41949 from nextcloud/backport/stable28/40169
[stable28] enh(settings): Load from disabled users endpoint
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/src/components/UserList.vue27
-rw-r--r--apps/settings/src/store/users.js36
-rw-r--r--apps/user_ldap/lib/User_LDAP.php2
-rw-r--r--apps/user_ldap/lib/User_Proxy.php2
4 files changed, 59 insertions, 8 deletions
diff --git a/apps/settings/src/components/UserList.vue b/apps/settings/src/components/UserList.vue
index 5c7e9ba4dda..92c823e8bc5 100644
--- a/apps/settings/src/components/UserList.vue
+++ b/apps/settings/src/components/UserList.vue
@@ -223,6 +223,14 @@ export default {
return this.$store.getters.getUsersLimit
},
+ disabledUsersOffset() {
+ return this.$store.getters.getDisabledUsersOffset
+ },
+
+ disabledUsersLimit() {
+ return this.$store.getters.getDisabledUsersLimit
+ },
+
usersCount() {
return this.users.length
},
@@ -297,12 +305,19 @@ export default {
async loadUsers() {
this.loading.users = true
try {
- await this.$store.dispatch('getUsers', {
- offset: this.usersOffset,
- limit: this.usersLimit,
- group: this.selectedGroup !== 'disabled' ? this.selectedGroup : '',
- search: this.searchQuery,
- })
+ if (this.selectedGroup === 'disabled') {
+ await this.$store.dispatch('getDisabledUsers', {
+ offset: this.disabledUsersOffset,
+ limit: this.disabledUsersLimit,
+ })
+ } else {
+ await this.$store.dispatch('getUsers', {
+ offset: this.usersOffset,
+ limit: this.usersLimit,
+ group: this.selectedGroup,
+ search: this.searchQuery,
+ })
+ }
logger.debug(`${this.users.length} total user(s) loaded`)
} catch (error) {
logger.error('Failed to load users', { error })
diff --git a/apps/settings/src/store/users.js b/apps/settings/src/store/users.js
index b031f768fd1..2682415a016 100644
--- a/apps/settings/src/store/users.js
+++ b/apps/settings/src/store/users.js
@@ -63,6 +63,8 @@ const state = {
minPasswordLength: 0,
usersOffset: 0,
usersLimit: 25,
+ disabledUsersOffset: 0,
+ disabledUsersLimit: 25,
userCount: 0,
showConfig: {
showStoragePath: false,
@@ -83,6 +85,9 @@ const mutations = {
state.usersOffset += state.usersLimit
state.users = users
},
+ updateDisabledUsers(state, _usersObj) {
+ state.disabledUsersOffset += state.disabledUsersLimit
+ },
setPasswordPolicyMinLength(state, length) {
state.minPasswordLength = length !== '' ? length : 0
},
@@ -237,6 +242,7 @@ const mutations = {
resetUsers(state) {
state.users = []
state.usersOffset = 0
+ state.disabledUsersOffset = 0
},
setShowConfig(state, { key, value }) {
@@ -264,6 +270,12 @@ const getters = {
getUsersLimit(state) {
return state.usersLimit
},
+ getDisabledUsersOffset(state) {
+ return state.disabledUsersOffset
+ },
+ getDisabledUsersLimit(state) {
+ return state.disabledUsersLimit
+ },
getUserCount(state) {
return state.userCount
},
@@ -373,6 +385,30 @@ const actions = {
})
},
+ /**
+ * Get disabled users with full details
+ *
+ * @param {object} context store context
+ * @param {object} options destructuring object
+ * @param {number} options.offset List offset to request
+ * @param {number} options.limit List number to return from offset
+ * @return {Promise<number>}
+ */
+ async getDisabledUsers(context, { offset, limit }) {
+ const url = generateOcsUrl('cloud/users/disabled?offset={offset}&limit={limit}', { offset, limit })
+ try {
+ const response = await api.get(url)
+ const usersCount = Object.keys(response.data.ocs.data.users).length
+ if (usersCount > 0) {
+ context.commit('appendUsers', response.data.ocs.data.users)
+ context.commit('updateDisabledUsers', response.data.ocs.data.users)
+ }
+ return usersCount
+ } catch (error) {
+ context.commit('API_FAILURE', error)
+ }
+ },
+
getGroups(context, { offset, limit, search }) {
search = typeof search === 'string' ? search : ''
const limitParam = limit === -1 ? '' : `&limit=${limit}`
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index f9ae6bbee66..d787bfea4d4 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -682,7 +682,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
return $enabled;
}
- public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
+ public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
throw new \Exception('This is implemented directly in User_Proxy');
}
}
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 919cddd99be..934bed7d450 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -463,7 +463,7 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
}
- public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
+ public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
return array_map(
fn (OfflineUser $user) => $user->getOCName(),
array_slice(