refactoring

This commit is contained in:
Čarodej
2022-01-21 09:55:11 +01:00
parent c2667ab481
commit aa28118d75
2 changed files with 41 additions and 24 deletions

View File

@@ -114,11 +114,7 @@
},
watch: {
'user.data.attributes.two_factor_authentication': function (val) {
if (val) {
this.open2faPopup()
} else {
this.disable()
}
val ? this.enable2faPopup() : this.disable2faPopup()
}
},
data() {
@@ -179,22 +175,6 @@
}
})
},
disable() {
axios
.delete('/user/two-factor-authentication')
.then(() => {
this.$store.commit('CHANGE_TWO_FACTOR_AUTHENTICATION_STATE', false)
})
.catch(() => {
this.$isSomethingWrong()
})
.finally(() => {
events.$emit('toaster', {
type: 'success',
message: this.$t('popup_2fa.toaster_disabled'),
})
})
},
getPersonalAccessTokens() {
axios.get('/api/user/tokens')
.then(response => {
@@ -210,7 +190,7 @@
}
})
},
open2faPopup() {
enable2faPopup() {
events.$emit('popup:open', {
name: 'confirm-password',
options: {
@@ -218,6 +198,14 @@
}
})
},
disable2faPopup() {
events.$emit('popup:open', {
name: 'confirm-password',
options: {
action: 'disable-2fa',
}
})
},
confirmDeleteToken(token) {
events.$emit('confirm:open', {
title: this.$t('popup_delete_personal_token.title'),
@@ -269,6 +257,26 @@
if (args.options.action === 'two-factor-qr-setup') {
events.$emit('popup:open', {name: 'two-factor-qr-setup'})
}
// Get 2fa qr code
if (args.options.action === 'disable-2fa') {
axios
.delete('/user/two-factor-authentication')
.then(() => {
this.$store.commit('CHANGE_TWO_FACTOR_AUTHENTICATION_STATE', false)
})
.catch(() => {
this.$isSomethingWrong()
})
.finally(() => {
this.$closePopup()
events.$emit('toaster', {
type: 'success',
message: this.$t('popup_2fa.toaster_disabled'),
})
})
}
})
events.$on('reload-personal-access-tokens', () => this.getPersonalAccessTokens())