27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
import request from './index'
|
||
|
||
export const authApi = {
|
||
login(username, password) {
|
||
return request.post('/auth/login', { username, password })
|
||
},
|
||
getCurrentUser() {
|
||
return request.get('/auth/me')
|
||
},
|
||
// 当前用户被授权的公司列表,不需要组织头。
|
||
listOrganizations() {
|
||
return request.get('/auth/organizations')
|
||
},
|
||
// 切换公司上下文:服务端校验授权并返回目标公司的仓库摘要,不需要组织头。
|
||
switchOrganizationContext(organizationId, previousOrganizationId = 0) {
|
||
return request.post('/auth/organization-context', {
|
||
organization_id: organizationId,
|
||
previous_organization_id: previousOrganizationId
|
||
})
|
||
},
|
||
// 换取 WebSocket 短期一次性票据:属于组织级请求,拦截器会自动带上当前公司头。
|
||
// 标记 silent:取票失败属于后台辅助失败,不应弹与实时连接相关的全局错误提示。
|
||
createWebSocketTicket() {
|
||
return request.post('/auth/websocket-ticket', undefined, { silent: true })
|
||
}
|
||
}
|