From 7fca9cdf3c08b97c099c7c2d1f110137d5f03876 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Thu, 23 Jan 2020 17:07:05 +0100 Subject: [PATCH] Fix account loading when requesting an OTD --- resources/js/components/TwofaccountShow.vue | 15 ++++++++------- resources/js/views/Accounts.vue | 11 ++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/resources/js/components/TwofaccountShow.vue b/resources/js/components/TwofaccountShow.vue index bae39ec0..546f09ea 100644 --- a/resources/js/components/TwofaccountShow.vue +++ b/resources/js/components/TwofaccountShow.vue @@ -16,6 +16,7 @@ export default { data() { return { + id: null, service: '', account: '', icon: '', @@ -25,29 +26,29 @@ } }, - props: ['twofaccountid'], - methods: { - getAccount: function() { + getAccount: function(id) { - axios.get('api/twofaccounts/' + this.twofaccountid) + this.id = id + + axios.get('api/twofaccounts/' + this.id) .then(response => { this.service = response.data.service this.account = response.data.account this.icon = response.data.icon - this.getOTP(this.twofaccountid) + this.getOTP() }) .catch(error => { this.$router.push({ name: 'genericError', params: { err: error.response } }); }); }, - getOTP: function(id) { + getOTP: function() { - axios.get('api/twofaccounts/' + id + '/totp').then(response => { + axios.get('api/twofaccounts/' + this.id + '/totp').then(response => { let spacePosition = Math.ceil(response.data.totp.length / 2); this.totp = response.data.totp.substr(0, spacePosition) + " " + response.data.totp.substr(spacePosition); diff --git a/resources/js/views/Accounts.vue b/resources/js/views/Accounts.vue index a32367d3..af4935cb 100644 --- a/resources/js/views/Accounts.vue +++ b/resources/js/views/Accounts.vue @@ -138,9 +138,14 @@ methods: { async showAccount(id) { - - this.$refs.TwofaccountShow.twofaccountid = id - await this.$refs.TwofaccountShow.getAccount() + + if( id ) { + await this.$refs.TwofaccountShow.getAccount(id) + } + else { + let err = new Error("Id missing") + this.$router.push({ name: 'genericError', params: { err: err } }); + } this.ShowTwofaccountInModal = true