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.

93 lines
3.0 KiB

  1. <template lang='pug'>
  2. v-card
  3. v-toolbar(flat, color='primary', dark, dense)
  4. .subtitle-1 {{ $t('admin:utilities.authTitle') }}
  5. v-card-text
  6. .subtitle-1.pb-3.primary--text Generate New Authentication Public / Private Key Certificates
  7. .body-2 This will invalidate all current session tokens and cause all users to be logged out.
  8. .body-2.red--text You will need to log back in after the operation.
  9. v-btn(outlined, color='primary', @click='regenCerts', :disabled='loading').ml-0.mt-3
  10. v-icon(left) mdi-gesture-double-tap
  11. span Proceed
  12. v-divider.my-5
  13. .subtitle-1.pb-3.primary--text Reset Guest User
  14. .body-2 This will reset the guest user to its default parameters and permissions.
  15. v-btn(outlined, color='primary', @click='resetGuest', :disabled='loading').ml-0.mt-3
  16. v-icon(left) mdi-gesture-double-tap
  17. span Proceed
  18. </template>
  19. <script>
  20. import _ from 'lodash'
  21. import Cookies from 'js-cookie'
  22. import utilityAuthRegencertsMutation from 'gql/admin/utilities/utilities-mutation-auth-regencerts.gql'
  23. import utilityAuthResetguestMutation from 'gql/admin/utilities/utilities-mutation-auth-resetguest.gql'
  24. export default {
  25. data: () => {
  26. return {
  27. loading: false
  28. }
  29. },
  30. methods: {
  31. async regenCerts() {
  32. this.loading = true
  33. this.$store.commit(`loadingStart`, 'admin-utilities-auth-regencerts')
  34. try {
  35. const respRaw = await this.$apollo.mutate({
  36. mutation: utilityAuthRegencertsMutation
  37. })
  38. const resp = _.get(respRaw, 'data.authentication.regenerateCertificates.responseResult', {})
  39. if (resp.succeeded) {
  40. this.$store.commit('showNotification', {
  41. message: 'New Certificates generated successfully.',
  42. style: 'success',
  43. icon: 'check'
  44. })
  45. Cookies.remove('jwt')
  46. _.delay(() => {
  47. window.location.assign('/login')
  48. }, 1000)
  49. } else {
  50. throw new Error(resp.message)
  51. }
  52. } catch (err) {
  53. this.$store.commit('pushGraphError', err)
  54. }
  55. this.$store.commit(`loadingStop`, 'admin-utilities-auth-regencerts')
  56. this.loading = false
  57. },
  58. async resetGuest() {
  59. this.loading = true
  60. this.$store.commit(`loadingStart`, 'admin-utilities-auth-resetguest')
  61. try {
  62. const respRaw = await this.$apollo.mutate({
  63. mutation: utilityAuthResetguestMutation
  64. })
  65. const resp = _.get(respRaw, 'data.authentication.resetGuestUser.responseResult', {})
  66. if (resp.succeeded) {
  67. this.$store.commit('showNotification', {
  68. message: 'Guest user was reset successfully.',
  69. style: 'success',
  70. icon: 'check'
  71. })
  72. } else {
  73. throw new Error(resp.message)
  74. }
  75. } catch (err) {
  76. this.$store.commit('pushGraphError', err)
  77. }
  78. this.$store.commit(`loadingStop`, 'admin-utilities-auth-resetguest')
  79. this.loading = false
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang='scss'>
  85. </style>