Skip to content

Commit

Permalink
fix: prevent autologin from crashing the app
Browse files Browse the repository at this point in the history
  • Loading branch information
n13 committed Oct 24, 2024
1 parent 81b97de commit f96923d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/store/accounts/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,20 @@ export const logout = async function ({ commit }) {
}

export const autoLogin = async function ({ dispatch }) {
if (typeof window.LightWalletChannel === 'object') {
return !dispatch('lightWalletLogin')
}

const wallet = localStorage.getItem('autoLogin')
const idx = this.$ual.authenticators.findIndex(auth => auth.ualName === wallet)
if (idx !== -1) {
const authenticator = this.$ual.authenticators[idx]
await authenticator.init()
return !dispatch('loginWallet', { idx })
try {
if (typeof window.LightWalletChannel === 'object') {
return !dispatch('lightWalletLogin')
}
const wallet = localStorage.getItem('autoLogin')
const idx = this.$ual.authenticators.findIndex(auth => auth.ualName === wallet)
if (idx !== -1) {
const authenticator = this.$ual.authenticators[idx]
await authenticator.init()
return !dispatch('loginWallet', { idx })
}
} catch (err) {
console.log('autologin error - logging out.')
localStorage.clear()
}
return false
}
Expand Down

0 comments on commit f96923d

Please sign in to comment.