admin-auth.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template lang='pug'>
  2. v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
  3. .pa-3.pt-4
  4. .headline.primary--text Authentication
  5. .subheading.grey--text Configure the authentication settings of your wiki
  6. v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
  7. v-tab(key='settings'): v-icon settings
  8. v-tab(v-for='strategy in activeStrategies', :key='strategy.key') {{ strategy.title }}
  9. v-tab-item(key='settings', :transition='false', :reverse-transition='false')
  10. v-card.pa-3(flat, tile)
  11. v-subheader.pl-0.pb-2 Select which authentication strategies to enable:
  12. v-form
  13. v-checkbox(
  14. v-for='strategy in strategies',
  15. v-model='selectedStrategies',
  16. :key='strategy.key',
  17. :label='strategy.title',
  18. :value='strategy.key',
  19. color='primary',
  20. :disabled='strategy.key === `local`'
  21. hide-details
  22. )
  23. v-tab-item(v-for='(strategy, n) in activeStrategies', :key='strategy.key', :transition='false', :reverse-transition='false')
  24. v-card.pa-3(flat, tile)
  25. v-form
  26. v-subheader.pl-0 Strategy Configuration
  27. .body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
  28. v-text-field(v-else, v-for='cfg in strategy.config', :key='cfg.key', :label='cfg.key', prepend-icon='settings_applications')
  29. v-divider
  30. v-subheader.pl-0 Registration
  31. v-switch.ml-3(
  32. v-model='auths',
  33. label='Allow self-registration',
  34. :value='true',
  35. color='primary',
  36. hint='Allow any user successfully authorized by the strategy to access the wiki.',
  37. persistent-hint
  38. )
  39. v-text-field.ml-3(label='Limit to specific email domains', prepend-icon='mail_outline')
  40. v-text-field.ml-3(label='Assign to group', prepend-icon='people')
  41. v-card-chin
  42. v-btn(color='primary')
  43. v-icon(left) chevron_right
  44. span Save
  45. v-spacer
  46. v-btn(icon, @click='refresh')
  47. v-icon.grey--text refresh
  48. </template>
  49. <script>
  50. import _ from 'lodash'
  51. import strategiesQuery from 'gql/admin-auth-query-strategies.gql'
  52. import strategiesSaveMutation from 'gql/admin-auth-mutation-save-strategies.gql'
  53. export default {
  54. data() {
  55. return {
  56. strategies: [],
  57. selectedStrategies: ['local']
  58. }
  59. },
  60. computed: {
  61. activeStrategies() {
  62. return _.filter(this.strategies, prv => _.includes(this.selectedStrategies, prv.key))
  63. }
  64. },
  65. methods: {
  66. async refresh() {
  67. await this.$apollo.queries.strategies.refetch()
  68. this.$store.commit('showNotification', {
  69. message: 'List of strategies has been refreshed.',
  70. style: 'success',
  71. icon: 'cached'
  72. })
  73. },
  74. async saveProviders() {
  75. this.$store.commit(`loadingStart`, 'admin-auth-savestrategies')
  76. await this.$apollo.mutate({
  77. mutation: strategiesSaveMutation,
  78. variables: {
  79. strategies: this.auths
  80. }
  81. })
  82. this.$store.commit(`loadingStop`, 'admin-auth-savestrategies')
  83. }
  84. },
  85. apollo: {
  86. strategies: {
  87. query: strategiesQuery,
  88. fetchPolicy: 'network-only',
  89. update: (data) => data.authentication.strategies,
  90. watchLoading (isLoading) {
  91. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang='scss'>
  98. </style>