REVIEW 单点登录界面

This commit is contained in:
YunaiV
2023-04-09 00:21:27 +08:00
parent 0f0ba8b8a9
commit 276e82c5a8
6 changed files with 162 additions and 196 deletions

View File

@ -1,13 +1,6 @@
import request from '@/config/axios'
import { getRefreshToken } from '@/utils/auth'
import type { UserLoginVO } from './types'
import { service } from '@/config/axios/service'
export interface CodeImgResult {
captchaOnOff: boolean
img: string
uuid: string
}
export interface SmsCodeVO {
mobile: string
@ -74,51 +67,3 @@ export const getCode = (data) => {
export const reqCheck = (data) => {
return request.postOriginal({ url: 'system/captcha/check', data })
}
// ========== OAUTH 2.0 相关 ==========
export type scopesType = string[]
export interface paramsType {
responseType: string
clientId: string
redirectUri: string
state: string
scopes: scopesType
}
export const getAuthorize = (clientId) => {
return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId })
}
export function authorize(
responseType: string,
clientId: string,
redirectUri: string,
state: string,
autoApprove: boolean,
checkedScopes: scopesType,
uncheckedScopes: scopesType
) {
// 构建 scopes
const scopes = {}
for (const scope of checkedScopes) {
scopes[scope] = true
}
for (const scope of uncheckedScopes) {
scopes[scope] = false
}
// 发起请求
return service({
url: '/system/oauth2/authorize',
headers: {
'Content-type': 'application/x-www-form-urlencoded'
},
params: {
response_type: responseType,
client_id: clientId,
redirect_uri: redirectUri,
state: state,
auto_approve: autoApprove,
scope: JSON.stringify(scopes)
},
method: 'post'
})
}