token
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,3 +20,5 @@ yarn-error.log*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw*
|
||||
|
||||
configSec.js
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
module.exports={
|
||||
// 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置:
|
||||
// sslType: 'greenlock',
|
||||
// sslDomainList: [''],
|
||||
// sslKey: '/etc/letsencrypt/live/test.bittic.net/privkey.pem', // ssl key file,
|
||||
// sslCert: '/etc/letsencrypt/live/test.bittic.net/fullchain.pem', // ssl cert file,
|
||||
// sslCA: '/etc/letsencrypt/live/test.bittic.net/bundle.crt', // ssl ca file,
|
||||
}
|
||||
@@ -32,14 +32,6 @@ const router = new Router({
|
||||
path: 'network',
|
||||
component: Network,
|
||||
},
|
||||
{
|
||||
path: 'chain',
|
||||
component: Chain,
|
||||
},
|
||||
{
|
||||
path: 'market',
|
||||
component: Market,
|
||||
},
|
||||
{
|
||||
path: '*',
|
||||
redirect: 'owner',
|
||||
@@ -49,18 +41,18 @@ const router = new Router({
|
||||
],
|
||||
})
|
||||
|
||||
// router.beforeEach((to, _, next) => {
|
||||
// const loginPage = to.path === '/login'
|
||||
// const signed = store.getters.isLogin
|
||||
// if (!loginPage && !signed) {
|
||||
// next('/login')
|
||||
// return
|
||||
// }
|
||||
// if (loginPage && signed) {
|
||||
// next('/home')
|
||||
// return
|
||||
// }
|
||||
// next()
|
||||
// })
|
||||
router.beforeEach((to, _, next) => {
|
||||
const loginPage = to.path === '/login'
|
||||
const signed = store.getters.isLogin
|
||||
if (!loginPage && !signed) {
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
if (loginPage && signed) {
|
||||
next('/home')
|
||||
return
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -2,7 +2,7 @@ import axios from 'axios'
|
||||
// import app from './app'
|
||||
// let baseURL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/api/`
|
||||
// let baseURL = `${location.protocol}//${location.hostname}:80/api/`
|
||||
let baseURL = `http://localhost:80/v1/`
|
||||
let baseURL = `https://server.vic.yuanjin.net/v1/`
|
||||
|
||||
// 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者让用户在控制台启动时,自己设置一个节点主机。
|
||||
axios.defaults.baseURL = baseURL
|
||||
|
||||
@@ -5,6 +5,7 @@ import _ from 'lodash'
|
||||
import ticCrypto from 'tic.crypto'
|
||||
import axios from 'axios'
|
||||
import * as Ticrypto from 'tic.crypto'
|
||||
import { tokenSec } from '../../../configSec'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@@ -46,10 +47,12 @@ export default {
|
||||
|
||||
actions: {
|
||||
async login({ state, commit }) {
|
||||
console.log(state)
|
||||
commit('updateSign', true)
|
||||
const passwd = Ticrypto.hash(state.passwd)
|
||||
let result = await axios.post('admin/in', { name: state.username, passwd })
|
||||
const ts = Date.now()
|
||||
const path = '/admin/in'
|
||||
const sig = ticCrypto.hash(ts + path + tokenSec, { hasher: 'md5' })
|
||||
let result = await axios.post('admin/in', { name: state.username, passwd }, { headers: { ts, sig } })
|
||||
commit('updateSign', false)
|
||||
if (result.data.code === 0) {
|
||||
commit('updateAccount', result.data.data, { root: true })
|
||||
|
||||
Reference in New Issue
Block a user