Move Account getter to Twofaccount component (to fix)

This commit is contained in:
Bubka
2020-01-22 17:32:41 +01:00
parent 59e96a9491
commit 8bfd812c70
2 changed files with 28 additions and 32 deletions

View File

@@ -16,19 +16,38 @@
export default {
data() {
return {
service: '',
account: '',
icon: '',
totp : '',
timerID: null,
position: null,
AccountId : null
}
},
props: ['twofaccountid', 'service', 'account', 'icon'],
props: ['twofaccountid'],
methods: {
getOTP: function () {
axios.get('api/twofaccounts/' + this.AccountId + '/totp').then(response => {
getAccount: function() {
axios.get('api/twofaccounts/' + this.twofaccountid)
.then(response => {
this.service = response.data.service
this.account = response.data.account
this.icon = response.data.icon
this.getOTP(this.twofaccountid)
})
.catch(error => {
this.$router.push({ name: 'genericError', params: { err: error.response } });
});
},
getOTP: function(id) {
axios.get('api/twofaccounts/' + 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);