fe-drone-ci/src/mock/login.js

35 lines
794 B
JavaScript
Raw Normal View History

2017-08-28 05:12:44 +00:00
import { param2Obj } from '@/utils'
2017-05-15 09:56:45 +00:00
2017-04-18 07:09:13 +00:00
const userMap = {
admin: {
role: ['admin'],
token: 'admin',
introduction: '我是超级管理员',
2017-05-31 08:49:24 +00:00
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
2017-07-06 09:56:17 +00:00
name: 'Super Admin'
2017-04-18 07:09:13 +00:00
},
editor: {
role: ['editor'],
token: 'editor',
introduction: '我是编辑',
2017-05-31 08:49:24 +00:00
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
2017-07-06 09:56:17 +00:00
name: 'Normal Editor'
2017-04-18 07:09:13 +00:00
}
}
2017-04-24 06:15:42 +00:00
export default {
2017-08-22 06:26:19 +00:00
loginByUsername: config => {
2017-08-22 07:43:34 +00:00
const { username } = JSON.parse(config.body)
return userMap[username]
2017-04-24 06:15:42 +00:00
},
2017-08-23 03:39:16 +00:00
getUserInfo: config => {
2017-08-22 07:43:34 +00:00
const { token } = param2Obj(config.url)
2017-05-15 09:56:45 +00:00
if (userMap[token]) {
2017-08-22 07:43:34 +00:00
return userMap[token]
2017-05-15 09:56:45 +00:00
} else {
2017-10-25 09:12:36 +00:00
return false
2017-05-15 09:56:45 +00:00
}
2017-04-24 06:15:42 +00:00
},
2017-05-15 09:56:45 +00:00
logout: () => 'success'
2017-08-22 07:43:34 +00:00
}