mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-19 19:28:08 +02:00
Move Account getter to Twofaccount component (to fix)
This commit is contained in:
parent
59e96a9491
commit
8bfd812c70
@ -16,19 +16,38 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
service: '',
|
||||||
|
account: '',
|
||||||
|
icon: '',
|
||||||
totp : '',
|
totp : '',
|
||||||
timerID: null,
|
timerID: null,
|
||||||
position: null,
|
position: null,
|
||||||
AccountId : null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
props: ['twofaccountid', 'service', 'account', 'icon'],
|
props: ['twofaccountid'],
|
||||||
|
|
||||||
methods: {
|
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);
|
let spacePosition = Math.ceil(response.data.totp.length / 2);
|
||||||
|
|
||||||
this.totp = response.data.totp.substr(0, spacePosition) + " " + response.data.totp.substr(spacePosition);
|
this.totp = response.data.totp.substr(0, spacePosition) + " " + response.data.totp.substr(spacePosition);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="buttons are-large is-centered">
|
<div class="buttons are-large is-centered">
|
||||||
<span v-for="account in filteredAccounts" class="button is-black has-background-black-bis twofaccount" >
|
<span v-for="account in filteredAccounts" class="button is-black has-background-black-bis twofaccount" >
|
||||||
<span @click.stop="getAccount(account.id)">
|
<span @click.stop="showAccount(account.id)">
|
||||||
<img :src="'storage/icons/' + account.icon" v-if="account.icon">
|
<img :src="'storage/icons/' + account.icon" v-if="account.icon">
|
||||||
{{ account.service }}
|
{{ account.service }}
|
||||||
<span class="is-family-primary is-size-7 has-text-grey">{{ account.account }}</span>
|
<span class="is-family-primary is-size-7 has-text-grey">{{ account.account }}</span>
|
||||||
@ -40,13 +40,7 @@
|
|||||||
<router-link :to="{ name: 'create' }" class="button is-medium is-link is-focused">{{ $t('twofaccounts.add_one') }}</router-link>
|
<router-link :to="{ name: 'create' }" class="button is-medium is-link is-focused">{{ $t('twofaccounts.add_one') }}</router-link>
|
||||||
</div>
|
</div>
|
||||||
<modal v-model="ShowTwofaccountInModal">
|
<modal v-model="ShowTwofaccountInModal">
|
||||||
<twofaccount-show
|
<twofaccount-show ref="TwofaccountShow" ></twofaccount-show>
|
||||||
:twofaccountid='twofaccount.id'
|
|
||||||
:service='twofaccount.service'
|
|
||||||
:icon='twofaccount.icon'
|
|
||||||
:account='twofaccount.account'
|
|
||||||
ref="TwofaccountShow" >
|
|
||||||
</twofaccount-show>
|
|
||||||
</modal>
|
</modal>
|
||||||
<footer class="has-background-black-ter">
|
<footer class="has-background-black-ter">
|
||||||
<div class="columns is-gapless" v-if="this.accounts.length > 0">
|
<div class="columns is-gapless" v-if="this.accounts.length > 0">
|
||||||
@ -90,9 +84,7 @@
|
|||||||
return {
|
return {
|
||||||
accounts : [],
|
accounts : [],
|
||||||
ShowTwofaccountInModal : false,
|
ShowTwofaccountInModal : false,
|
||||||
twofaccount: {},
|
|
||||||
search: '',
|
search: '',
|
||||||
token : null,
|
|
||||||
username : null,
|
username : null,
|
||||||
editMode: this.InitialEditMode,
|
editMode: this.InitialEditMode,
|
||||||
showAccounts: null,
|
showAccounts: null,
|
||||||
@ -135,11 +127,6 @@
|
|||||||
this.$on('modalClose', function() {
|
this.$on('modalClose', function() {
|
||||||
console.log('modalClose triggered')
|
console.log('modalClose triggered')
|
||||||
this.$refs.TwofaccountShow.clearOTP()
|
this.$refs.TwofaccountShow.clearOTP()
|
||||||
|
|
||||||
this.twofaccount.id = ''
|
|
||||||
this.twofaccount.service = ''
|
|
||||||
this.twofaccount.account = ''
|
|
||||||
this.twofaccount.icon = ''
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -150,20 +137,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async getAccount(id) {
|
async showAccount(id) {
|
||||||
|
|
||||||
const { data } = await axios.get('api/twofaccounts/' + id)
|
this.$refs.TwofaccountShow.twofaccountid = id
|
||||||
.catch(error => {
|
await this.$refs.TwofaccountShow.getAccount()
|
||||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.twofaccount.id = data.id
|
|
||||||
this.twofaccount.service = data.service
|
|
||||||
this.twofaccount.account = data.account
|
|
||||||
this.twofaccount.icon = data.icon
|
|
||||||
|
|
||||||
this.$refs.TwofaccountShow.AccountId = data.id
|
|
||||||
await this.$refs.TwofaccountShow.getOTP()
|
|
||||||
|
|
||||||
this.ShowTwofaccountInModal = true
|
this.ShowTwofaccountInModal = true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user