123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import qs from 'qs'
- import Request from '../..'
- enum Api {
- GetTenant = '/workspace/tenant/identifier',
- Login = '/auth/oauth2/token',
- LogOut = '/auth/token/logout',
- LoginByMobile = '/auth/mobile/token/sms'
- }
- export interface GetTenantParmas {
- identifier: string
- }
- export interface GetTenantResult {
- nickname: string
- tenantId: number
- tenantLevel: string
- tenantLogo: string
- }
- /** 登录-结果 */
- export interface LoginResult {
- access_token: string
- token_type: string
- refresh_token: string
- expires_in: number
- scope: string
- license: string
- active: boolean
- user_id: number
- client_id: string
- username: string
- }
- export function getTenantByName(data: GetTenantParmas) {
- return Request.get<GetTenantResult>({
- url: Api.GetTenant,
- params: data
- })
- }
- // 登录
- export const loginByUsername = (
- username: string,
- password: string,
- code: string,
- randomStr: string
- ) => {
- const grant_type = 'password'
- const dataObj = qs.stringify({ username: username, password: password })
- console.log(randomStr)
- return Request.post<LoginResult, false>({
- url: Api.Login,
- headers: {
- isToken: false,
- Authorization: 'Basic d2ViOndlYg=='
- },
- params: { randomStr, grant_type, code, scope: 'server' },
- data: dataObj
- })
- }
|