material_manage_system/frontend/src/api/auth.js

27 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 })
}
}