2019-12-03 18:03:25 +00:00
|
|
|
|
|
|
|
const tokens = {
|
|
|
|
admin: {
|
|
|
|
token: 'admin-token'
|
|
|
|
},
|
|
|
|
editor: {
|
|
|
|
token: 'editor-token'
|
2019-12-03 22:03:26 +00:00
|
|
|
},
|
|
|
|
user: {
|
|
|
|
token: 'editor-token'
|
2019-12-03 18:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const users = {
|
|
|
|
'admin-token': {
|
|
|
|
roles: ['admin'],
|
2020-01-06 13:36:58 +00:00
|
|
|
introduction: 'Projektmanager bei Styria',
|
|
|
|
avatar: 'https://lbsfilm.at/media/pages/about/1056669128-1567191147/square-small.jpg',
|
|
|
|
name: 'Lukas Bachschwell'
|
2019-12-03 18:03:25 +00:00
|
|
|
},
|
|
|
|
'editor-token': {
|
|
|
|
roles: ['editor'],
|
2020-01-06 13:36:58 +00:00
|
|
|
introduction: 'Manager bei Styria',
|
2020-01-06 14:40:54 +00:00
|
|
|
avatar: 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse4.mm.bing.net%2Fth%3Fid%3DOIP.mJ3OSG9AD98jJSXYhB89_QAAAA%26pid%3DApi&f=1',
|
2020-01-08 12:27:12 +00:00
|
|
|
name: 'Wolfgang Römer'
|
2019-12-03 18:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default [
|
|
|
|
// user login
|
|
|
|
{
|
|
|
|
url: '/user/login',
|
|
|
|
type: 'post',
|
|
|
|
response: config => {
|
|
|
|
const { username } = config.body
|
|
|
|
const token = tokens[username]
|
|
|
|
|
|
|
|
// mock error
|
|
|
|
if (!token) {
|
|
|
|
return {
|
|
|
|
code: 60204,
|
|
|
|
message: 'Account and password are incorrect.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// get user info
|
|
|
|
{
|
|
|
|
url: '/user/info\.*',
|
|
|
|
type: 'get',
|
|
|
|
response: config => {
|
|
|
|
const { token } = config.query
|
|
|
|
const info = users[token]
|
|
|
|
|
|
|
|
// mock error
|
|
|
|
if (!info) {
|
|
|
|
return {
|
|
|
|
code: 50008,
|
|
|
|
message: 'Login failed, unable to get user details.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: info
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// user logout
|
|
|
|
{
|
|
|
|
url: '/user/logout',
|
|
|
|
type: 'post',
|
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: 'success'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|