summaryrefslogtreecommitdiffstats
path: root/settings/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-15 18:22:19 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-16 09:50:25 +0200
commite23e28b3cc311c9820462b38c6a7958027540dd7 (patch)
tree7e1022ca576dcfc7b9969858c45f6bfca55dd36b /settings/src
parentbcffbab6f8afb29c9e5c8ef9861739febdb06a09 (diff)
downloadnextcloud-server-e23e28b3cc311c9820462b38c6a7958027540dd7.tar.gz
nextcloud-server-e23e28b3cc311c9820462b38c6a7958027540dd7.zip
Various fixes
* Fixed subadmin group management * Fixed pass policy prop retrieving * Fixed fields subadmins were not supposed to see Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'settings/src')
-rw-r--r--settings/src/components/userList.vue20
-rw-r--r--settings/src/components/userList/userRow.vue7
-rw-r--r--settings/src/store/index.js3
-rw-r--r--settings/src/store/users.js12
-rw-r--r--settings/src/views/Users.vue2
5 files changed, 28 insertions, 16 deletions
diff --git a/settings/src/components/userList.vue b/settings/src/components/userList.vue
index 7ef95a314b5..d9ece700434 100644
--- a/settings/src/components/userList.vue
+++ b/settings/src/components/userList.vue
@@ -8,7 +8,7 @@
<div id="headerAddress" class="mailAddress">{{ t('settings', 'Email') }}</div>
<div id="headerGroups" class="groups">{{ t('settings', 'Groups') }}</div>
<div id="headerSubAdmins" class="subadmins"
- v-if="subAdminsGroups.length>0">{{ t('settings', 'Group admin for') }}</div>
+ v-if="subAdminsGroups.length>0 && settings.isAdmin">{{ t('settings', 'Group admin for') }}</div>
<div id="headerQuota" class="quota">{{ t('settings', 'Quota') }}</div>
<div id="headerLanguages" class="languages"
v-if="showConfig.showLanguages">{{ t('settings', 'Languages') }}</div>
@@ -50,19 +50,26 @@
autocomplete="off" autocapitalize="none" autocorrect="off">
</div>
<div class="groups">
+ <!-- hidden input trick for vanilla html5 form validation -->
+ <input type="text" :value="newUser.groups" v-if="!settings.isAdmin"
+ tabindex="-1" id="newgroups" :required="!settings.isAdmin" />
<multiselect :options="groups" v-model="newUser.groups"
:placeholder="t('settings', 'Add user in group')"
label="name" track-by="id" class="multiselect-vue"
- :multiple="true" :close-on-select="false">
- <span slot="noResult">{{t('settings','No result')}}</span>
+ :multiple="true" :close-on-select="false"
+ :allowEmpty="settings.isAdmin">
+ <!-- If user is not admin, he is a subadmin.
+ Subadmins can't create users outside their groups
+ Therefore, empty select is forbidden -->
+ <span slot="noResult">{{t('settings', 'No results')}}</span>
</multiselect>
</div>
- <div class="subadmins" v-if="subAdminsGroups.length>0">
+ <div class="subadmins" v-if="subAdminsGroups.length>0 && settings.isAdmin">
<multiselect :options="subAdminsGroups" v-model="newUser.subAdminsGroups"
:placeholder="t('settings', 'Set user as admin for')"
label="name" track-by="id" class="multiselect-vue"
:multiple="true" :close-on-select="false">
- <span slot="noResult">{{t('settings','No result')}}</span>
+ <span slot="noResult">{{t('settings', 'No results')}}</span>
</multiselect>
</div>
<div class="quota">
@@ -269,7 +276,8 @@ export default {
subadmin: this.newUser.subAdminsGroups.map(group => group.id),
quota: this.newUser.quota.id,
language: this.newUser.language.code,
- }).then(() => this.resetForm());
+ }).then(() => this.resetForm())
+ .catch(() => this.loading = false);
},
setNewUserDefaultGroup(value) {
if (value && value.length > 0) {
diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue
index 78c20122bc0..c3250f951b0 100644
--- a/settings/src/components/userList/userRow.vue
+++ b/settings/src/components/userList/userRow.vue
@@ -34,18 +34,19 @@
tag-placeholder="create" :placeholder="t('settings', 'Add user in group')"
label="name" track-by="id" class="multiselect-vue"
:limit="2" :limitText="limitGroups"
- :multiple="true" :taggable="true" :closeOnSelect="false"
+ :multiple="true" :taggable="settings.isAdmin" :closeOnSelect="false"
@tag="createGroup" @select="addUserGroup" @remove="removeUserGroup">
+ <span slot="noResult">{{t('settings', 'No results')}}</span>
</multiselect>
</div>
- <div class="subadmins" v-if="subAdminsGroups.length>0" :class="{'icon-loading-small': loading.subadmins}">
+ <div class="subadmins" v-if="subAdminsGroups.length>0 && settings.isAdmin" :class="{'icon-loading-small': loading.subadmins}">
<multiselect :value="userSubAdminsGroups" :options="subAdminsGroups" :disabled="loading.subadmins||loading.all"
:placeholder="t('settings', 'Set user as admin for')"
label="name" track-by="id" class="multiselect-vue"
:limit="2" :limitText="limitGroups"
:multiple="true" :closeOnSelect="false"
@select="addUserSubAdmin" @remove="removeUserSubAdmin">
- <span slot="noResult">{{t('settings','No result')}}</span>
+ <span slot="noResult">{{t('settings', 'No results')}}</span>
</multiselect>
</div>
<div class="quota" :class="{'icon-loading-small': loading.quota}">
diff --git a/settings/src/store/index.js b/settings/src/store/index.js
index bf08e4aa390..43de49e2030 100644
--- a/settings/src/store/index.js
+++ b/settings/src/store/index.js
@@ -10,8 +10,9 @@ const debug = process.env.NODE_ENV !== 'production';
const mutations = {
API_FAILURE(state, error) {
- console.log(state, error);
OC.Notification.showTemporary(t('settings','An error occured during the request. Unable to proceed.'));
+ // throw to raise exception of the promise and allow a `.then` in the Vue methods
+ throw error;
}
};
diff --git a/settings/src/store/users.js b/settings/src/store/users.js
index 052a2918390..f349c7b4a06 100644
--- a/settings/src/store/users.js
+++ b/settings/src/store/users.js
@@ -213,9 +213,11 @@ const actions = {
getPasswordPolicyMinLength(context) {
- return api.get(OC.linkToOCS('apps/provisioning_api/api/v1/config/apps/password_policy/minLength', 2))
- .then((response) => context.commit('setPasswordPolicyMinLength', response.data.ocs.data.data))
- .catch((error) => context.commit('API_FAILURE', error));
+ if(oc_capabilities.password_policy && oc_capabilities.password_policy.minLength) {
+ context.commit('setPasswordPolicyMinLength', oc_capabilities.password_policy.minLength);
+ return oc_capabilities.password_policy.minLength;
+ }
+ return false;
},
/**
@@ -344,12 +346,12 @@ const actions = {
* @param {string} options.quota User email
* @returns {Promise}
*/
- addUser({context, dispatch}, { userid, password, email, groups, subadmin, quota, language }) {
+ addUser({commit, dispatch}, { userid, password, email, groups, subadmin, quota, language }) {
return api.requireAdmin().then((response) => {
return api.post(OC.linkToOCS(`cloud/users`, 2), { userid, password, email, groups, subadmin, quota, language })
.then((response) => dispatch('addUserData', userid))
.catch((error) => {throw error;});
- }).catch((error) => context.commit('API_FAILURE', { userid, error }));
+ }).catch((error) => commit('API_FAILURE', { userid, error }));
},
/**
diff --git a/settings/src/views/Users.vue b/settings/src/views/Users.vue
index d154ebc03f9..c88487635a9 100644
--- a/settings/src/views/Users.vue
+++ b/settings/src/views/Users.vue
@@ -241,7 +241,7 @@ export default {
item.text = group.name; // group name
item.utils = {counter: group.usercount}; // users count
- if (item.id !== 'admin' && item.id !== 'disabled') {
+ if (item.id !== 'admin' && item.id !== 'disabled' && this.settings.isAdmin) {
// add delete button on real groups
let self = this;
item.utils.actions = [{