feat: enable/disable TFA per user
This commit is contained in:
@@ -70,33 +70,33 @@
|
||||
)
|
||||
|
||||
v-flex(lg6 xs12)
|
||||
v-card.animated.fadeInUp.wait-p2s
|
||||
v-toolbar(color='teal', dark, dense, flat)
|
||||
v-toolbar-title.subtitle-1 {{$t('admin:theme.downloadThemes')}}
|
||||
v-spacer
|
||||
v-chip(label, color='white', small).teal--text coming soon
|
||||
v-data-table(
|
||||
:headers='headers',
|
||||
:items='themes',
|
||||
hide-default-footer,
|
||||
item-key='value',
|
||||
:items-per-page='1000'
|
||||
)
|
||||
template(v-slot:item='thm')
|
||||
td
|
||||
strong {{thm.item.text}}
|
||||
td
|
||||
span {{ thm.item.author }}
|
||||
td.text-xs-center
|
||||
v-progress-circular(v-if='thm.item.isDownloading', indeterminate, color='blue', size='20', :width='2')
|
||||
v-btn(v-else-if='thm.item.isInstalled && thm.item.installDate < thm.item.updatedAt', icon)
|
||||
v-icon.blue--text mdi-cached
|
||||
v-btn(v-else-if='thm.item.isInstalled', icon)
|
||||
v-icon.green--text mdi-check-bold
|
||||
v-btn(v-else, icon)
|
||||
v-icon.grey--text mdi-cloud-download
|
||||
//- v-card.animated.fadeInUp.wait-p2s
|
||||
//- v-toolbar(color='teal', dark, dense, flat)
|
||||
//- v-toolbar-title.subtitle-1 {{$t('admin:theme.downloadThemes')}}
|
||||
//- v-spacer
|
||||
//- v-chip(label, color='white', small).teal--text coming soon
|
||||
//- v-data-table(
|
||||
//- :headers='headers',
|
||||
//- :items='themes',
|
||||
//- hide-default-footer,
|
||||
//- item-key='value',
|
||||
//- :items-per-page='1000'
|
||||
//- )
|
||||
//- template(v-slot:item='thm')
|
||||
//- td
|
||||
//- strong {{thm.item.text}}
|
||||
//- td
|
||||
//- span {{ thm.item.author }}
|
||||
//- td.text-xs-center
|
||||
//- v-progress-circular(v-if='thm.item.isDownloading', indeterminate, color='blue', size='20', :width='2')
|
||||
//- v-btn(v-else-if='thm.item.isInstalled && thm.item.installDate < thm.item.updatedAt', icon)
|
||||
//- v-icon.blue--text mdi-cached
|
||||
//- v-btn(v-else-if='thm.item.isInstalled', icon)
|
||||
//- v-icon.green--text mdi-check-bold
|
||||
//- v-btn(v-else, icon)
|
||||
//- v-icon.grey--text mdi-cloud-download
|
||||
|
||||
v-card.mt-3.animated.fadeInUp.wait-p2s
|
||||
v-card.animated.fadeInUp.wait-p2s
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title.subtitle-1 {{$t(`admin:theme.codeInjection`)}}
|
||||
v-card-text
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user