2019-03-18 10:07:55 +00:00
|
|
|
|
|
|
|
const tokens = {
|
2017-04-18 07:09:13 +00:00
|
|
|
admin: {
|
2019-03-18 10:07:55 +00:00
|
|
|
token: 'admin-token'
|
|
|
|
},
|
|
|
|
editor: {
|
|
|
|
token: 'editor-token'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const users = {
|
|
|
|
'admin-token': {
|
2018-01-05 03:38:34 +00:00
|
|
|
roles: ['admin'],
|
2019-03-18 10:07:55 +00:00
|
|
|
introduction: 'I am a super administrator',
|
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
|
|
|
},
|
2019-03-18 10:07:55 +00:00
|
|
|
'editor-token': {
|
2018-01-05 03:38:34 +00:00
|
|
|
roles: ['editor'],
|
2019-03-18 10:07:55 +00:00
|
|
|
introduction: 'I am an editor',
|
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 [
|
2019-03-18 10:07:55 +00:00
|
|
|
// user login
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
2019-03-18 10:07:55 +00:00
|
|
|
url: '/user/login',
|
2019-03-18 07:51:48 +00:00
|
|
|
type: 'post',
|
|
|
|
response: config => {
|
|
|
|
const { username } = config.body
|
2019-03-19 10:46:30 +00:00
|
|
|
return {
|
2019-03-20 03:00:54 +00:00
|
|
|
code: 20000,
|
2019-03-19 10:46:30 +00:00
|
|
|
data: tokens[username]
|
|
|
|
}
|
2019-03-18 07:51:48 +00:00
|
|
|
}
|
2017-04-24 06:15:42 +00:00
|
|
|
},
|
2019-03-18 10:07:55 +00:00
|
|
|
|
|
|
|
// get user info
|
2019-03-18 07:51:48 +00:00
|
|
|
{
|
|
|
|
url: '/user/info\.*',
|
|
|
|
type: 'get',
|
|
|
|
response: config => {
|
|
|
|
const { token } = config.query
|
2019-03-19 10:46:30 +00:00
|
|
|
return {
|
2019-03-20 03:00:54 +00:00
|
|
|
code: 20000,
|
2019-03-19 10:46:30 +00:00
|
|
|
data: users[token]
|
|
|
|
}
|
2019-03-18 10:07:55 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// user logout
|
|
|
|
{
|
|
|
|
url: '/user/logout',
|
|
|
|
type: 'post',
|
|
|
|
response: _ => {
|
|
|
|
return {
|
2019-03-20 03:00:54 +00:00
|
|
|
code: 20000,
|
2019-03-18 10:07:55 +00:00
|
|
|
data: 'success'
|
2019-03-18 07:51:48 +00:00
|
|
|
}
|
2017-05-15 09:56:45 +00:00
|
|
|
}
|
2018-10-29 05:55:36 +00:00
|
|
|
}
|
2019-03-18 07:51:48 +00:00
|
|
|
]
|