简化登录报错的信息
This commit is contained in:
parent
f942160131
commit
551ae030cc
@ -275,13 +275,13 @@ export class Blockchain {
|
|||||||
public async disconnect() {
|
public async disconnect() {
|
||||||
try {
|
try {
|
||||||
await UserModule.LogOut()
|
await UserModule.LogOut()
|
||||||
await this.provider?.disconnect()
|
|
||||||
this.currentChain = 0
|
this.currentChain = 0
|
||||||
this.walletType = 0
|
this.walletType = 0
|
||||||
this.coinInstanceMap.clear()
|
this.coinInstanceMap.clear()
|
||||||
this.clearCachedProvider()
|
this.clearCachedProvider()
|
||||||
AppModule.updateStep(0)
|
AppModule.updateStep(0)
|
||||||
AppModule.updateNonce('')
|
AppModule.updateNonce('')
|
||||||
|
await this.provider?.disconnect()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
}
|
}
|
||||||
this.clearCachedProvider()
|
this.clearCachedProvider()
|
||||||
|
@ -40,7 +40,7 @@ class User extends VuexModule implements IUserState {
|
|||||||
public sex = '0'
|
public sex = '0'
|
||||||
public account = ''
|
public account = ''
|
||||||
|
|
||||||
@Action
|
@Action({ rawError: true })
|
||||||
public async Login({ bcInstance, account, chainId, nonce }: {bcInstance: any, account: string, chainId: string | number, nonce: string}) {
|
public async Login({ bcInstance, account, chainId, nonce }: {bcInstance: any, account: string, chainId: string | number, nonce: string}) {
|
||||||
nonce += ''
|
nonce += ''
|
||||||
const tips = 'This signature is only used for verify your account'
|
const tips = 'This signature is only used for verify your account'
|
||||||
|
@ -33,33 +33,15 @@ service.interceptors.response.use(
|
|||||||
(response) => {
|
(response) => {
|
||||||
// Some example codes here:
|
// Some example codes here:
|
||||||
// code == 0: success
|
// code == 0: success
|
||||||
// code == 50001: invalid access token
|
|
||||||
// code == 50002: already login in other place
|
|
||||||
// code == 50003: access token expired
|
|
||||||
// code == 50004: invalid user (user not exist)
|
|
||||||
// code == 10: username or password is incorrect
|
// code == 10: username or password is incorrect
|
||||||
// You can change this part for your own usage.
|
// You can change this part for your own usage.
|
||||||
const res = response.data
|
const res = response.data
|
||||||
if (res.errcode) {
|
if (res.errcode) {
|
||||||
Message({
|
// Message({
|
||||||
message: res.errmsg || 'Error',
|
// message: res.errmsg || 'Error',
|
||||||
type: 'error',
|
// type: 'error',
|
||||||
duration: 5 * 1000
|
// duration: 5 * 1000
|
||||||
})
|
// })
|
||||||
if (res.errcode === 50008 || res.errcode === 50012 || res.errcode === 50014) {
|
|
||||||
MessageBox.confirm(
|
|
||||||
'You have been logged out, try to login again.',
|
|
||||||
'Log out',
|
|
||||||
{
|
|
||||||
confirmButtonText: 'Relogin',
|
|
||||||
cancelButtonText: 'Cancel',
|
|
||||||
type: 'warning'
|
|
||||||
}
|
|
||||||
).then(() => {
|
|
||||||
UserModule.ResetToken()
|
|
||||||
location.reload() // To prevent bugs from vue-router
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return Promise.reject(new Error(res.errmsg || 'Error'))
|
return Promise.reject(new Error(res.errmsg || 'Error'))
|
||||||
} else {
|
} else {
|
||||||
return response.data
|
return response.data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user