1
This commit is contained in:
parent
41ee9ada74
commit
5bcefe2f27
@ -9,7 +9,7 @@ export function login(data) {
|
||||
}
|
||||
export function metamaskLogin(data) {
|
||||
return request({
|
||||
url: '/user/metamask-login',
|
||||
url: '/user/metamask_login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
@ -35,4 +35,3 @@ export function getNonce(account) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { login, logout, getInfo } from '@/api/user'
|
||||
import { login, logout, getInfo, metamaskLogin } from '@/api/user'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import router, { resetRouter } from '@/router'
|
||||
|
||||
@ -44,6 +44,19 @@ const actions = {
|
||||
})
|
||||
},
|
||||
|
||||
metamaskLogin({ commit }, authData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
metamaskLogin(authData).then(response => {
|
||||
const { token } = response
|
||||
commit('SET_TOKEN', token)
|
||||
setToken(token)
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// get user info
|
||||
getInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -18,7 +18,7 @@
|
||||
<script>
|
||||
// import openWindow from '@/utils/open-window'
|
||||
import Web3 from 'web3'
|
||||
import { getNonce, metamaskLogin } from '@/api/user'
|
||||
import { getNonce } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'SocialSignin',
|
||||
@ -161,12 +161,14 @@ export default {
|
||||
tips,
|
||||
net_id
|
||||
}
|
||||
metamaskLogin(authData).then(response => {
|
||||
this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
|
||||
console.log(response)
|
||||
}).catch((err) => {
|
||||
console.log('Api getNonce Error:' + err)
|
||||
})
|
||||
this.$store.dispatch('user/metamaskLogin', authData)
|
||||
.then(() => {
|
||||
this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
|
||||
this.loading = false
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
async signData(signObj, signer) {
|
||||
const msgParams = JSON.stringify(signObj)
|
||||
|
@ -42,6 +42,7 @@ module.exports = {
|
||||
// provide the app's title in webpack's name field, so that
|
||||
// it can be accessed in index.html to inject the correct title.
|
||||
name: name,
|
||||
devtool: 'source-map',
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src')
|
||||
|
Loading…
x
Reference in New Issue
Block a user