From 1c1e3386f802e05488a480c5fb451c9437851fde Mon Sep 17 00:00:00 2001 From: ZhengJin Date: Mon, 28 Jul 2025 17:52:59 +0800 Subject: [PATCH] Update api.js --- web/src/helpers/api.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/src/helpers/api.js b/web/src/helpers/api.js index 55228fd8..294e1775 100644 --- a/web/src/helpers/api.js +++ b/web/src/helpers/api.js @@ -215,14 +215,16 @@ export async function getOAuthState() { export async function onOIDCClicked(auth_url, client_id, openInNewTab = false) { const state = await getOAuthState(); if (!state) return; - const redirect_uri = `${window.location.origin}/oauth/oidc`; - const response_type = 'code'; - const scope = 'openid profile email'; - const url = `${auth_url}?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=${response_type}&scope=${scope}&state=${state}`; + const url = new URL(auth_url); + url.searchParams.set('client_id', client_id); + url.searchParams.set('redirect_uri', `${window.location.origin}/oauth/oidc`); + url.searchParams.set('response_type', 'code'); + url.searchParams.set('scope', 'openid profile email'); + url.searchParams.set('state', state); if (openInNewTab) { - window.open(url); + window.open(url.toString(), '_blank'); } else { - window.location.href = url; + window.location.href = url.toString(); } }