zhongrj
2024-05-07 4b0a798f81ea4ad201421ae02fa896d55a20beb0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import request from '@/router/axios';
import website from "@/config/website";
 
export const loginByUsername = (tenantId, deptId, roleId, username, password, type, key, code) => request({
  url: '/api/oauth/token',
  method: 'post',
  headers: {
    'Tenant-Id': tenantId,
    'Dept-Id': (website.switchMode ? deptId : ''),
    'Role-Id': (website.switchMode ? roleId : ''),
    // 'Captcha-Key': key,
    // 'Captcha-Code': code,
  },
  params: {
    tenantId,
    username,
    password,
    grant_type:"password",
    scope: "all",
    type
  }
});
 
export const loginForm = (tenant_id,  username, password) => request({
  url: '/api/oauth/form',
  method: 'post',
  headers:{
    'Content-Type':"application/x-www-form-urlencoded"
  },
  params: {
    tenant_id,
    username,
    password
  }
});
 
export const loginBySocial = (tenantId, source, code, state) => request({
  url: '/api/oauth/token',
  method: 'post',
  headers: {
    'Tenant-Id': tenantId
  },
  params: {
    tenantId,
    source,
    code,
    state,
    grant_type: "social",
    scope: "all",
  }
})
 
export const loginBySso = (state, code) => request({
  url: '/api/oauth/token',
  method: 'post',
  headers: {
    'Tenant-Id': state
  },
  params: {
    tenantId: state,
    code,
    grant_type: "authorization_code",
    scope: "all",
    redirect_uri: website.redirectUri,
  }
})
 
export const refreshToken = (refresh_token, tenantId, deptId, roleId) => request({
  url: '/api/oauth/token',
  method: 'post',
  headers: {
    'Tenant-Id': tenantId,
    'Dept-Id': (website.switchMode ? deptId : ''),
    'Role-Id': (website.switchMode ? roleId : '')
  },
  params: {
    tenantId,
    refresh_token,
    grant_type: "refresh_token",
    scope: "all",
  }
});
 
export const registerGuest = (form, oauthId) => request({
  url: '/api//user/register-guest',
  method: 'post',
  params: {
    tenantId: form.tenantId,
    name: form.name,
    account: form.account,
    password: form.password,
    oauthId
  }
});
 
export const getButtons = () => request({
  url: '/api//menu/buttons',
  method: 'get'
});
 
export const getCaptcha = () => request({
  url: '/api/blade-auth/oauth/captcha',
  method: 'get',
  authorization: false
});
 
export const logout = () => request({
  url: '/api/blade-auth/oauth/logout',
  method: 'get',
  authorization: false
});
 
export const getUserInfo = () => request({
  url: '/api/blade-auth/oauth/user-info',
  method: 'get'
});
 
export const sendLogs = (list) => request({
  url: '/api/blade-auth/oauth/logout',
  method: 'post',
  data: list
});
 
export const clearCache = () => request({
  url: '/api/blade-auth/oauth/clear-cache',
  method: 'get',
  authorization: false
});