aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/src/components/AdminTwoFactor.vue
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-25 18:19:42 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-10-01 17:16:09 +0200
commitb9bc2417e7a8dc81feb0abe20359bedaf864f790 (patch)
tree61b47fbf37c1d168da8625224debde9e6a985348 /apps/settings/src/components/AdminTwoFactor.vue
parent7fb651235128dcbca8a6683b5cdafdf835f46300 (diff)
downloadnextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.tar.gz
nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.zip
Comply to eslint
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/settings/src/components/AdminTwoFactor.vue')
-rw-r--r--apps/settings/src/components/AdminTwoFactor.vue209
1 files changed, 103 insertions, 106 deletions
diff --git a/apps/settings/src/components/AdminTwoFactor.vue b/apps/settings/src/components/AdminTwoFactor.vue
index a1f28f5cfdd..934b77928dc 100644
--- a/apps/settings/src/components/AdminTwoFactor.vue
+++ b/apps/settings/src/components/AdminTwoFactor.vue
@@ -4,14 +4,14 @@
{{ t('settings', 'Two-factor authentication can be enforced for all users and specific groups. If they do not have a two-factor provider configured, they will be unable to log into the system.') }}
</p>
<p v-if="loading">
- <span class="icon-loading-small two-factor-loading"></span>
+ <span class="icon-loading-small two-factor-loading" />
<span>{{ t('settings', 'Enforce two-factor authentication') }}</span>
</p>
<p v-else>
- <input type="checkbox"
- id="two-factor-enforced"
- class="checkbox"
- v-model="enforced">
+ <input id="two-factor-enforced"
+ v-model="enforced"
+ type="checkbox"
+ class="checkbox">
<label for="two-factor-enforced">{{ t('settings', 'Enforce two-factor authentication') }}</label>
</p>
<template v-if="enforced">
@@ -22,32 +22,30 @@
</p>
<p>
<Multiselect v-model="enforcedGroups"
- :options="groups"
- :placeholder="t('settings', 'Enforced groups')"
- :disabled="loading"
- :multiple="true"
- :searchable="true"
- @search-change="searchGroup"
- :loading="loadingGroups"
- :show-no-options="false"
- :close-on-select="false">
- </Multiselect>
+ :options="groups"
+ :placeholder="t('settings', 'Enforced groups')"
+ :disabled="loading"
+ :multiple="true"
+ :searchable="true"
+ :loading="loadingGroups"
+ :show-no-options="false"
+ :close-on-select="false"
+ @search-change="searchGroup" />
</p>
<p>
{{ t('settings', 'Two-factor authentication is not enforced for members of the following groups.') }}
</p>
<p>
<Multiselect v-model="excludedGroups"
- :options="groups"
- :placeholder="t('settings', 'Excluded groups')"
- :disabled="loading"
- :multiple="true"
- :searchable="true"
- @search-change="searchGroup"
- :loading="loadingGroups"
- :show-no-options="false"
- :close-on-select="false">
- </Multiselect>
+ :options="groups"
+ :placeholder="t('settings', 'Excluded groups')"
+ :disabled="loading"
+ :multiple="true"
+ :searchable="true"
+ :loading="loadingGroups"
+ :show-no-options="false"
+ :close-on-select="false"
+ @search-change="searchGroup" />
</p>
<p>
<em>
@@ -57,10 +55,10 @@
</p>
</template>
<p>
- <button class="button primary"
- v-if="dirty"
- v-on:click="saveChanges"
- :disabled="loading">
+ <button v-if="dirty"
+ class="button primary"
+ :disabled="loading"
+ @click="saveChanges">
{{ t('settings', 'Save changes') }}
</button>
</p>
@@ -68,94 +66,93 @@
</template>
<script>
- import Axios from 'nextcloud-axios'
- import { mapState } from 'vuex'
- import {Multiselect} from 'nextcloud-vue'
- import _ from 'lodash'
+import axios from 'nextcloud-axios'
+import { Multiselect } from 'nextcloud-vue'
+import _ from 'lodash'
- export default {
- name: "AdminTwoFactor",
- components: {
- Multiselect
- },
- data () {
- return {
- loading: false,
- dirty: false,
- groups: [],
- loadingGroups: false,
+export default {
+ name: 'AdminTwoFactor',
+ components: {
+ Multiselect
+ },
+ data() {
+ return {
+ loading: false,
+ dirty: false,
+ groups: [],
+ loadingGroups: false
+ }
+ },
+ computed: {
+ enforced: {
+ get: function() {
+ return this.$store.state.enforced
+ },
+ set: function(val) {
+ this.dirty = true
+ this.$store.commit('setEnforced', val)
}
},
- computed: {
- enforced: {
- get: function () {
- return this.$store.state.enforced
- },
- set: function (val) {
- this.dirty = true
- this.$store.commit('setEnforced', val)
- }
- },
- enforcedGroups: {
- get: function () {
- return this.$store.state.enforcedGroups
- },
- set: function (val) {
- this.dirty = true
- this.$store.commit('setEnforcedGroups', val)
- }
- },
- excludedGroups: {
- get: function () {
- return this.$store.state.excludedGroups
- },
- set: function (val) {
- this.dirty = true
- this.$store.commit('setExcludedGroups', val)
- }
+ enforcedGroups: {
+ get: function() {
+ return this.$store.state.enforcedGroups
},
+ set: function(val) {
+ this.dirty = true
+ this.$store.commit('setEnforcedGroups', val)
+ }
},
- mounted () {
- // Groups are loaded dynamically, but the assigned ones *should*
- // be valid groups, so let's add them as initial state
- this.groups = _.sortedUniq(_.uniq(this.enforcedGroups.concat(this.excludedGroups)))
+ excludedGroups: {
+ get: function() {
+ return this.$store.state.excludedGroups
+ },
+ set: function(val) {
+ this.dirty = true
+ this.$store.commit('setExcludedGroups', val)
+ }
+ }
+ },
+ mounted() {
+ // Groups are loaded dynamically, but the assigned ones *should*
+ // be valid groups, so let's add them as initial state
+ this.groups = _.sortedUniq(_.uniq(this.enforcedGroups.concat(this.excludedGroups)))
- // Populate the groups with a first set so the dropdown is not empty
- // when opening the page the first time
- this.searchGroup('')
- },
- methods: {
- searchGroup: _.debounce(function (query) {
- this.loadingGroups = true
- Axios.get(OC.linkToOCS(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2))
- .then(res => res.data.ocs)
- .then(ocs => ocs.data.groups)
- .then(groups => this.groups = _.sortedUniq(_.uniq(this.groups.concat(groups))))
- .catch(err => console.error('could not search groups', err))
- .then(() => this.loadingGroups = false)
- }, 500),
+ // Populate the groups with a first set so the dropdown is not empty
+ // when opening the page the first time
+ this.searchGroup('')
+ },
+ methods: {
+ searchGroup: _.debounce(function(query) {
+ this.loadingGroups = true
+ axios.get(OC.linkToOCS(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2))
+ .then(res => res.data.ocs)
+ .then(ocs => ocs.data.groups)
+ .then(groups => { this.groups = _.sortedUniq(_.uniq(this.groups.concat(groups))) })
+ .catch(err => console.error('could not search groups', err))
+ .then(() => { this.loadingGroups = false })
+ }, 500),
- saveChanges () {
- this.loading = true
+ saveChanges() {
+ this.loading = true
- const data = {
- enforced: this.enforced,
- enforcedGroups: this.enforcedGroups,
- excludedGroups: this.excludedGroups,
- }
- Axios.put(OC.generateUrl('/settings/api/admin/twofactorauth'), data)
- .then(resp => resp.data)
- .then(state => {
- this.state = state
- this.dirty = false
- })
- .catch(err => {
- console.error('could not save changes', err)
- })
- .then(() => this.loading = false)
+ const data = {
+ enforced: this.enforced,
+ enforcedGroups: this.enforcedGroups,
+ excludedGroups: this.excludedGroups
}
+ axios.put(OC.generateUrl('/settings/api/admin/twofactorauth'), data)
+ .then(resp => resp.data)
+ .then(state => {
+ this.state = state
+ this.dirty = false
+ })
+ .catch(err => {
+ console.error('could not save changes', err)
+ })
+ .then(() => { this.loading = false })
}
}
+}
</script>
<style>