fe-drone-ci/mock/login.js

49 lines
954 B
JavaScript
Raw Normal View History

2017-04-18 07:09:13 +00:00
const userMap = {
admin: {
2018-01-05 03:38:34 +00:00
roles: ['admin'],
2017-04-18 07:09:13 +00:00
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: {
2018-01-05 03:38:34 +00:00
roles: ['editor'],
2017-04-18 07:09:13 +00:00
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
2019-03-18 07:51:48 +00:00
export default [
{
url: '/login/login',
type: 'post',
response: config => {
const { username } = config.body
return userMap[username]
}
},
{
url: '/login/logout',
type: 'post',
response: _ => {
return {
data: 'success'
}
}
2017-04-24 06:15:42 +00:00
},
2019-03-18 07:51:48 +00:00
{
url: '/user/info\.*',
type: 'get',
response: config => {
const { token } = config.query
if (userMap[token]) {
return userMap[token]
} else {
return false
}
2017-05-15 09:56:45 +00:00
}
}
2019-03-18 07:51:48 +00:00
]