mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-23 21:41:44 +02:00
Fix account loading when requesting an OTD
This commit is contained in:
parent
326866e1c7
commit
7fca9cdf3c
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user