Fix account loading when requesting an OTD

This commit is contained in:
Bubka 2020-01-23 17:07:05 +01:00
parent 326866e1c7
commit 7fca9cdf3c
2 changed files with 16 additions and 10 deletions

View File

@ -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);

View File

@ -139,8 +139,13 @@
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