Skip to content

Commit

Permalink
fix signup with metamask
Browse files Browse the repository at this point in the history
  • Loading branch information
slavas490 committed Dec 11, 2023
1 parent ad9ed28 commit e8dcae7
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions ui/core/src/views/RegisterRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,36 +147,48 @@ export default {
await window.ethereum.enable()
await this.app.wallet.wallet.setupDefaultAccount()
} catch (e) {
console.log(e)
this.app.deleteUserHasSession()
this.walletErrorMessage = this.$t('Please grant access to MetaMask.')
return
}
} else {
this.app.deleteUserHasSession()
this.walletErrorMessage = this.$t('Please grant access to MetaMask.')
return
}
this.account = this.app.wallet.getCurrentAddress()
if (this.account === undefined) {
this.app.deleteUserHasSession()
this.walletErrorMessage = this.$t('Please sign in to MetaMask.')
return
}
if (this.checkTermsAndConditions()) {
this.app.wallet.signMessage(this.challenge, this.account).then((signature) => {
axios.post('/api/login', { signature }).then((res) => {
this.challenge = ''
if (res.status >= 200 && res.status <= 299) {
window.location = res.data.location || '/admin/workflow'
} else {
this.walletErrorMessage = this.$t('Could not verify signature.')
}
}, (err) => {
this.challenge = ''
this.app.handleError(err)
this.walletErrorMessage = this.$t('Could not verify signature.')
this.app.wallet.signMessage(this.challenge, this.account)
.then((signature) => {
axios.post('/api/login', { signature })
.then((res) => {
this.challenge = ''
if (res.status >= 200 && res.status <= 299) {
this.app.initUserHasSession()
window.location = res.data.location || '/admin/workflow'
} else {
this.app.deleteUserHasSession()
this.walletErrorMessage = this.$t('Could not verify signature.')
}
}, (err) => {
this.challenge = ''
this.app.deleteUserHasSession()
this.app.handleError(err)
this.walletErrorMessage = this.$t('Could not verify signature.')
})
}).catch(() => {
this.app.deleteUserHasSession()
this.walletErrorMessage = this.$t('Could not Sign Message.')
})
}).catch(() => {
this.walletErrorMessage = this.$t('Could not Sign Message.')
})
}
}
}
Expand Down

0 comments on commit e8dcae7

Please sign in to comment.