Skip to content

Commit 47fbdf3

Browse files
committed
fix: update redirect URL handling for authentication types in index.vue
1 parent bb08a16 commit 47fbdf3

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

ui/src/views/chat/user-login/index.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,25 +314,27 @@ function redirectAuth(authType: string, needMessage: boolean = false) {
314314
const config = res.data.config
315315
const queryParams = new URLSearchParams(route.query as any).toString()
316316
// 构造带查询参数的redirectUrl
317-
let redirectUrl = `${config.redirectUrl}/${accessToken}`
317+
let redirectUrl = `${config.redirectUrl}`
318+
let redirectUrlCallback = `${config.redirectUrl}/${accessToken}`
318319
if (queryParams) {
319-
redirectUrl += `?${queryParams}`
320+
redirectUrlCallback += `?${queryParams}`
321+
redirectUrl += `&${queryParams}`
320322
}
321323
let url
322324
if (authType === 'CAS') {
323325
url = config.ldpUri
324326
url +=
325327
url.indexOf('?') !== -1
326-
? `&service=${encodeURIComponent(redirectUrl)}`
327-
: `?service=${encodeURIComponent(redirectUrl)}`
328+
? `&service=${encodeURIComponent(redirectUrlCallback)}`
329+
: `?service=${encodeURIComponent(redirectUrlCallback)}`
328330
} else if (authType === 'OIDC') {
329331
const scope = config.scope || 'openid+profile+email'
330-
url = `${config.authEndpoint}?client_id=${config.clientId}&redirect_uri=${redirectUrl}&response_type=code&scope=${scope}`
332+
url = `${config.authEndpoint}?client_id=${config.clientId}&redirect_uri=${redirectUrlCallback}&response_type=code&scope=${scope}`
331333
if (config.state) {
332334
url += `&state=${config.state}`
333335
}
334336
} else if (authType === 'OAuth2') {
335-
url = `${config.authEndpoint}?client_id=${config.clientId}&response_type=code&redirect_uri=${redirectUrl}&state=${uuidv4()}`
337+
url = `${config.authEndpoint}?client_id=${config.clientId}&response_type=code&redirect_uri=${redirectUrl}&state=${accessToken}`
336338
if (config.scope) {
337339
url += `&scope=${config.scope}`
338340
}

0 commit comments

Comments
 (0)