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

41 lines
713 B
JavaScript
Raw Normal View History

2022-06-26 18:42:07 +08:00
import { resolveToken } from '../utils'
2022-01-08 17:20:46 +08:00
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),
},
}
},
},
]