wireguard-dashboard-admin/mock/auth/index.js

41 lines
714 B
JavaScript
Raw Normal View History

2022-01-08 17:20:46 +08:00
import { resolveToken } from '../_utils'
const token = {
admin: 'admin',
editor: 'editor',
}
export default [
{
2022-02-09 17:46:25 +08:00
url: '/api/auth/login',
2022-01-08 17:20:46 +08:00
method: 'post',
response: ({ body }) => {
if (['admin', 'editor'].includes(body?.name)) {
return {
code: 0,
data: {
token: token[body.name],
},
}
} else {
return {
code: -1,
message: '没有此用户',
}
}
},
},
{
2022-02-09 17:46:25 +08:00
url: '/api/auth/refreshToken',
2022-01-08 17:20:46 +08:00
method: 'post',
response: ({ headers }) => {
return {
code: 0,
data: {
token: resolveToken(headers?.authorization),
},
}
},
},
]