|
@@ -126,8 +126,6 @@
|
|
|
v-list-item-content
|
|
|
v-list-item-title {{$t('admin:users.authProvider')}}
|
|
|
v-list-item-subtitle {{ user.providerName }} #[em.caption ({{ user.providerKey }})]
|
|
|
- //- v-list-item-action
|
|
|
- //- v-img(src='https://static.requarks.io/logo/wikijs.svg', alt='', contain, max-height='32', position='center right')
|
|
|
template(v-if='user.providerKey === `local`')
|
|
|
v-divider
|
|
|
v-list-item
|
|
@@ -168,6 +166,7 @@
|
|
|
v-btn(icon, color='grey', x-small, v-on='on', disabled)
|
|
|
v-icon mdi-email
|
|
|
span Send Password Reset Email
|
|
|
+ template(v-if='user.providerIs2FACapable')
|
|
|
v-divider
|
|
|
v-list-item
|
|
|
v-list-item-avatar(size='32')
|
|
@@ -179,7 +178,7 @@
|
|
|
v-list-item-action
|
|
|
v-tooltip(top)
|
|
|
template(v-slot:activator='{ on }')
|
|
|
- v-btn(icon, color='grey', x-small, v-on='on', disabled)
|
|
|
+ v-btn(icon, color='grey', x-small, v-on='on', @click='toggle2FA')
|
|
|
v-icon mdi-power
|
|
|
span {{$t('admin:users.toggle2FA')}}
|
|
|
template(v-if='user.providerId')
|
|
@@ -941,6 +940,82 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
this.$store.commit(`loadingStop`, 'admin-users-verify')
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Toggle 2FA State
|
|
|
+ */
|
|
|
+ async toggle2FA () {
|
|
|
+ this.$store.commit(`loadingStart`, 'admin-users-toggle2fa')
|
|
|
+ if (this.user.tfaIsActive) {
|
|
|
+ const resp = await this.$apollo.mutate({
|
|
|
+ mutation: gql`
|
|
|
+ mutation ($id: Int!) {
|
|
|
+ users {
|
|
|
+ disableTFA(id: $id) {
|
|
|
+ responseResult {
|
|
|
+ succeeded
|
|
|
+ errorCode
|
|
|
+ slug
|
|
|
+ message
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ variables: {
|
|
|
+ id: this.user.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (_.get(resp, 'data.users.disableTFA.responseResult.succeeded', false)) {
|
|
|
+ this.$store.commit('showNotification', {
|
|
|
+ style: 'success',
|
|
|
+ message: this.$t('admin:users.userTFADisableSuccess'),
|
|
|
+ icon: 'check'
|
|
|
+ })
|
|
|
+ this.user.tfaIsActive = false
|
|
|
+ } else {
|
|
|
+ this.$store.commit('showNotification', {
|
|
|
+ style: 'red',
|
|
|
+ message: _.get(resp, 'data.users.disableTFA.responseResult.message', 'An unexpected error occurred.'),
|
|
|
+ icon: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const resp = await this.$apollo.mutate({
|
|
|
+ mutation: gql`
|
|
|
+ mutation ($id: Int!) {
|
|
|
+ users {
|
|
|
+ enableTFA(id: $id) {
|
|
|
+ responseResult {
|
|
|
+ succeeded
|
|
|
+ errorCode
|
|
|
+ slug
|
|
|
+ message
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ `,
|
|
|
+ variables: {
|
|
|
+ id: this.user.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (_.get(resp, 'data.users.enableTFA.responseResult.succeeded', false)) {
|
|
|
+ this.$store.commit('showNotification', {
|
|
|
+ style: 'success',
|
|
|
+ message: this.$t('admin:users.userTFAEnableSuccess'),
|
|
|
+ icon: 'check'
|
|
|
+ })
|
|
|
+ this.user.tfaIsActive = true
|
|
|
+ } else {
|
|
|
+ this.$store.commit('showNotification', {
|
|
|
+ style: 'red',
|
|
|
+ message: _.get(resp, 'data.users.enableTFA.responseResult.message', 'An unexpected error occurred.'),
|
|
|
+ icon: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$store.commit(`loadingStop`, 'admin-users-toggle2fa')
|
|
|
}
|
|
|
},
|
|
|
apollo: {
|
|
@@ -955,6 +1030,7 @@ export default {
|
|
|
providerKey
|
|
|
providerName
|
|
|
providerId
|
|
|
+ providerIs2FACapable
|
|
|
location
|
|
|
jobTitle
|
|
|
timezone
|