wikijs-fork/client/components/admin/admin-auth.vue

108 lines
3.6 KiB
Vue
Raw Normal View History

<template lang='pug'>
2018-06-10 00:11:00 +00:00
v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
2018-06-04 04:41:29 +00:00
.pa-3.pt-4
.headline.primary--text Authentication
.subheading.grey--text Configure the authentication settings of your wiki
2018-06-10 00:11:00 +00:00
v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
2018-06-04 04:41:29 +00:00
v-tab(key='settings'): v-icon settings
v-tab(v-for='strategy in activeStrategies', :key='strategy.key') {{ strategy.title }}
2018-06-04 04:41:29 +00:00
v-tab-item(key='settings', :transition='false', :reverse-transition='false')
v-card.pa-3(flat, tile)
v-subheader.pl-0.pb-2 Select which authentication strategies to enable:
v-form
v-checkbox(
v-for='strategy in strategies',
v-model='selectedStrategies',
:key='strategy.key',
:label='strategy.title',
:value='strategy.key',
color='primary',
:disabled='strategy.key === `local`'
hide-details
)
2018-06-04 04:41:29 +00:00
v-tab-item(v-for='(strategy, n) in activeStrategies', :key='strategy.key', :transition='false', :reverse-transition='false')
v-card.pa-3(flat, tile)
v-form
v-subheader.pl-0 Strategy Configuration
.body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
v-text-field(v-else, v-for='cfg in strategy.config', :key='cfg.key', :label='cfg.key', prepend-icon='settings_applications')
v-divider
v-subheader.pl-0 Registration
v-switch.ml-3(
v-model='auths',
label='Allow self-registration',
:value='true',
color='primary',
hint='Allow any user successfully authorized by the strategy to access the wiki.',
persistent-hint
)
v-text-field.ml-3(label='Limit to specific email domains', prepend-icon='mail_outline')
v-text-field.ml-3(label='Assign to group', prepend-icon='people')
2018-06-10 00:11:00 +00:00
v-card-chin
2018-06-04 04:41:29 +00:00
v-btn(color='primary')
v-icon(left) chevron_right
span Save
v-spacer
v-btn(icon, @click='refresh')
v-icon.grey--text refresh
</template>
<script>
import _ from 'lodash'
2018-06-04 04:41:29 +00:00
import strategiesQuery from 'gql/admin-auth-query-strategies.gql'
import strategiesSaveMutation from 'gql/admin-auth-mutation-save-strategies.gql'
export default {
data() {
return {
2018-06-04 04:41:29 +00:00
strategies: [],
selectedStrategies: ['local']
}
},
computed: {
2018-06-04 04:41:29 +00:00
activeStrategies() {
return _.filter(this.strategies, prv => _.includes(this.selectedStrategies, prv.key))
}
},
2018-06-04 04:41:29 +00:00
methods: {
async refresh() {
await this.$apollo.queries.strategies.refetch()
this.$store.commit('showNotification', {
message: 'List of strategies has been refreshed.',
style: 'success',
icon: 'cached'
})
},
async saveProviders() {
this.$store.commit(`loadingStart`, 'admin-auth-savestrategies')
await this.$apollo.mutate({
mutation: strategiesSaveMutation,
variables: {
strategies: this.auths
}
2018-06-04 04:41:29 +00:00
})
this.$store.commit(`loadingStop`, 'admin-auth-savestrategies')
}
},
2018-06-04 04:41:29 +00:00
apollo: {
strategies: {
query: strategiesQuery,
fetchPolicy: 'network-only',
update: (data) => data.authentication.strategies,
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
}
}
}
}
</script>
<style lang='scss'>
</style>