aboutsummaryrefslogtreecommitdiffstats
path: root/settings/src/components/AdminTwoFactor.vue
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2018-10-08 14:03:22 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2018-10-10 14:34:52 +0200
commit67c3730fbb8e12c6adda0af37d5a7ac8960415dc (patch)
tree4625e834d8812cff6c7f4a4bdae16ea9f8cda564 /settings/src/components/AdminTwoFactor.vue
parent1dbd7172c31b2d611e49c7c8a60a05da134a4733 (diff)
downloadnextcloud-server-67c3730fbb8e12c6adda0af37d5a7ac8960415dc.tar.gz
nextcloud-server-67c3730fbb8e12c6adda0af37d5a7ac8960415dc.zip
Add admin interface to enforce 2FA
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'settings/src/components/AdminTwoFactor.vue')
-rw-r--r--settings/src/components/AdminTwoFactor.vue76
1 files changed, 76 insertions, 0 deletions
diff --git a/settings/src/components/AdminTwoFactor.vue b/settings/src/components/AdminTwoFactor.vue
new file mode 100644
index 00000000000..a4ce482f70c
--- /dev/null
+++ b/settings/src/components/AdminTwoFactor.vue
@@ -0,0 +1,76 @@
+<template>
+ <div>
+ <p>
+ {{ t('settings', 'Two-factor authentication can be enforced for all users. 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>{{ t('settings', 'Enforce two-factor authentication') }}</span>
+ </p>
+ <p v-else>
+ <input type="checkbox"
+ id="two-factor-enforced"
+ class="checkbox"
+ v-model="enabled"
+ v-on:change="onEnforcedChanged">
+ <label for="two-factor-enforced">{{ t('settings', 'Enforce two-factor authentication') }}</label>
+ </p>
+ </div>
+</template>
+
+<script>
+ import Axios from 'nextcloud-axios'
+
+ export default {
+ name: "AdminTwoFactor",
+ data () {
+ return {
+ enabled: false,
+ loading: false
+ }
+ },
+ mounted () {
+ this.loading = true
+ Axios.get(OC.generateUrl('/settings/api/admin/twofactorauth'))
+ .then(resp => resp.data)
+ .then(state => {
+ this.enabled = state.enabled
+ this.loading = false
+ console.info('loaded')
+ })
+ .catch(err => {
+ console.error(error)
+ this.loading = false
+ throw err
+ })
+ },
+ methods: {
+ onEnforcedChanged () {
+ this.loading = true
+ const data = {
+ enabled: this.enabled
+ }
+ Axios.put(OC.generateUrl('/settings/api/admin/twofactorauth'), data)
+ .then(resp => resp.data)
+ .then(state => {
+ this.enabled = state.enabled
+ this.loading = false
+ })
+ .catch(err => {
+ console.error(error)
+ this.loading = false
+ throw err
+ })
+ }
+ }
+ }
+</script>
+
+<style>
+ .two-factor-loading {
+ display: inline-block;
+ vertical-align: sub;
+ margin-left: -2px;
+ margin-right: 1px;
+ }
+</style> \ No newline at end of file