const tokens = { admin: { token: 'admin-token' }, editor: { token: 'editor-token' }, user: { token: 'editor-token' } } const users = { 'admin-token': { roles: ['admin'], introduction: 'Projektmanager bei Styria', avatar: 'https://lbsfilm.at/media/pages/about/1056669128-1567191147/square-small.jpg', name: 'Lukas Bachschwell' }, 'editor-token': { roles: ['editor'], introduction: 'Manager bei Styria', avatar: 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse4.mm.bing.net%2Fth%3Fid%3DOIP.mJ3OSG9AD98jJSXYhB89_QAAAA%26pid%3DApi&f=1', name: 'Wolfgang Röemer' } } 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' } } } ]