You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

  1. <template lang="pug">
  2. transition(:duration="400")
  3. .modal(v-show='isShown', v-cloak)
  4. transition(name='modal-background')
  5. .modal-background(v-show='isShown')
  6. .modal-container
  7. transition(name='modal-content')
  8. .modal-content(v-show='isShown')
  9. template(v-if='step === "qr"')
  10. header.is-blue Setup your 2FA app
  11. section.modal-loading
  12. i
  13. span Wiki.js {{ mode }} in progress...
  14. em Please wait
  15. template(v-if='step === "error"')
  16. header.is-red Error
  17. section.modal-loading
  18. span {{ error }}
  19. footer
  20. a.button.is-grey.is-outlined(@click='cancel') Discard
  21. template(v-if='step === "confirm"')
  22. header.is-blue Two-Factor Authentication
  23. section
  24. label.label Do you want to enable 2FA?
  25. span.note Two-Factor Authentication (2FA) provides an extra layer of security for your account. Upon login, you will be prompted to enter a token generated by a 2FA app (e.g. Authy, Google Authenticator, etc.).
  26. footer
  27. a.button.is-grey.is-outlined(@click='cancel') Discard
  28. a.button.is-blue(@click='confirm') Setup
  29. </template>
  30. <script>
  31. export default {
  32. name: 'modal-profile-2fa',
  33. data() {
  34. return {
  35. isLoading: false,
  36. error: ''
  37. }
  38. },
  39. computed: {
  40. isShown() {
  41. return this.$store.state.modalProfile2fa.shown
  42. },
  43. step() {
  44. return this.$store.state.modalProfile2fa.step
  45. }
  46. },
  47. methods: {
  48. cancel() {
  49. this.isLoading = false
  50. this.$store.dispatch('modalProfile2fa/close')
  51. },
  52. confirm() {
  53. this.$http.post('/admin/profile/2fa', {
  54. action: 'setup'
  55. }).then(resp => {
  56. this.$store.commit('modalProfile2fa/stepChange', 'qr')
  57. }).catch(err => {
  58. this.$store.commit('modalProfile2fa/stepChange', 'error')
  59. this.error = err.body.msg
  60. })
  61. }
  62. }
  63. }
  64. </script>