Blame view
mock/user.js
1.99 KB
d7d9c38c2 auto commit the c... |
1 |
|
80a28914e init |
2 3 4 5 |
const tokens = { admin: { token: 'admin-token' }, |
3d3cdb68f auto commit the c... |
6 7 8 9 10 11 12 13 |
assistant: { token: 'assistant-token' }, runner: { token: 'runner-token' }, shoper: { token: 'shoper-token' |
80a28914e init |
14 15 16 17 |
} } const users = { |
d7d9c38c2 auto commit the c... |
18 |
'admin-token': { |
80a28914e init |
19 20 21 22 23 |
roles: ['admin'], introduction: 'I am a super administrator', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: 'Super Admin' }, |
3d3cdb68f auto commit the c... |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
'assistant-token': { roles: ['assistant'], introduction: 'I am an assistant', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: 'Normal assistant' }, 'runner-token': { roles: ['runner'], introduction: 'I am an runner', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: 'Normal runner' }, 'shoper-token': { roles: ['shoper'], introduction: 'I am an shoper', |
c44ba96f6 auto commit the c... |
39 |
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', |
3d3cdb68f auto commit the c... |
40 |
name: 'Normal shoper' |
80a28914e init |
41 42 |
} } |
d7d9c38c2 auto commit the c... |
43 44 45 46 |
export default [ // user login { url: '/vue-element-admin/user/login', |
80a28914e init |
47 48 |
type: 'post', response: config => { |
d7d9c38c2 auto commit the c... |
49 50 51 52 53 |
const { username } = config.body const token = tokens[username] // mock error if (!token) { |
80a28914e init |
54 55 |
return { code: 60204, |
d7d9c38c2 auto commit the c... |
56 |
message: 'Account and password are incorrect.' |
80a28914e init |
57 58 |
} } |
d7d9c38c2 auto commit the c... |
59 60 61 62 63 |
return { code: 20000, data: token } |
80a28914e init |
64 65 66 67 68 |
} }, // get user info { |
d7d9c38c2 auto commit the c... |
69 |
url: '/vue-element-admin/user/info\.*', |
80a28914e init |
70 71 |
type: 'get', response: config => { |
d7d9c38c2 auto commit the c... |
72 |
const { token } = config.query |
80a28914e init |
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
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 { |
d7d9c38c2 auto commit the c... |
92 |
url: '/vue-element-admin/user/logout', |
80a28914e init |
93 94 95 96 97 98 99 100 101 |
type: 'post', response: _ => { return { code: 20000, data: 'success' } } } ] |