diff options
Diffstat (limited to 'apps/twofactor_backupcodes/src/views/PersonalSettings.vue')
-rw-r--r-- | apps/twofactor_backupcodes/src/views/PersonalSettings.vue | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/apps/twofactor_backupcodes/src/views/PersonalSettings.vue b/apps/twofactor_backupcodes/src/views/PersonalSettings.vue index 0a9ac4b1d48..2ca389461c8 100644 --- a/apps/twofactor_backupcodes/src/views/PersonalSettings.vue +++ b/apps/twofactor_backupcodes/src/views/PersonalSettings.vue @@ -34,17 +34,13 @@ <script> import confirmPassword from 'nextcloud-password-confirmation'; - - import {getState, generateCodes} from '../service/BackupCodesService'; import {print} from '../service/PrintService'; export default { name: "PersonalSettings", data() { return { - enabled: false, generatingCodes: false, - codes: undefined }; }, computed: { @@ -55,30 +51,27 @@ return 'data:text/plain,' + encodeURIComponent(this.codes.reduce((prev, code) => { return prev + code + '\r\n'; }, '')); + }, + enabled: function() { + return this.$store.state.enabled + }, + total: function() { + return this.$store.state.total + }, + used: function() { + return this.$store.state.used + }, + codes: function() { + return this.$store.state.codes } }, - created: function() { - getState() - .then(state => { - this.enabled = state.enabled; - this.total = state.total; - this.used = state.used; - }) - .catch(console.error.bind(this)); - }, methods: { generateBackupCodes: function() { confirmPassword().then(() => { // Hide old codes - this.enabled = false; this.generatingCodes = true; - generateCodes().then(data => { - this.enabled = data.state.enabled; - this.total = data.state.total; - this.used = data.state.used; - this.codes = data.codes; - + this.$store.dispatch('generate').then(data => { this.generatingCodes = false; }).catch(err => { OC.Notification.showTemporary(t('twofactor_backupcodes', 'An error occurred while generating your backup codes')); |