From dcd63284985d0597727bdaf85d94ecae9b4a9970 Mon Sep 17 00:00:00 2001 From: Yixiang Zhao Date: Sat, 19 Mar 2022 20:01:44 +0800 Subject: [PATCH] fix: callback url param missing (#583) Signed-off-by: Yixiang Zhao --- web/src/auth/AuthCallback.js | 5 +++-- web/src/auth/LoginPage.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/auth/AuthCallback.js b/web/src/auth/AuthCallback.js index b80ff81f..9fcb7275 100644 --- a/web/src/auth/AuthCallback.js +++ b/web/src/auth/AuthCallback.js @@ -106,6 +106,7 @@ class AuthCallback extends React.Component { method: method, }; const oAuthParams = Util.getOAuthGetParameters(innerParams); + const concatChar = oAuthParams.redirectUri.indexOf('?') === -1 ? '?' : '&'; AuthBackend.login(body, oAuthParams) .then((res) => { if (res.status === 'ok') { @@ -118,11 +119,11 @@ class AuthCallback extends React.Component { Setting.goToLink(link); } else if (responseType === "code") { const code = res.data; - Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`); + Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`); // Util.showMessage("success", `Authorization code: ${res.data}`); } else if (responseType === "token" || responseType === "id_token"){ const token = res.data; - Setting.goToLink(`${oAuthParams.redirectUri}?${responseType}=${token}&state=${oAuthParams.state}&token_type=bearer`); + Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}${responseType}=${token}&state=${oAuthParams.state}&token_type=bearer`); } else if (responseType === "link") { const from = innerParams.get("from"); Setting.goToLinkSoft(this, from); diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index ed3fc69a..0333b832 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -138,6 +138,7 @@ class LoginPage extends React.Component { Setting.goToLink(link); } else if (responseType === "code") { const code = res.data; + const concatChar = oAuthParams.redirectUri.indexOf('?') === -1 ? '?' : '&'; if (Setting.hasPromptPage(application)) { AuthBackend.getAccount("") @@ -150,7 +151,7 @@ class LoginPage extends React.Component { this.onUpdateAccount(account); if (Setting.isPromptAnswered(account, application)) { - Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`); + Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`); } else { Setting.goToLinkSoft(ths, `/prompt/${application.name}?redirectUri=${oAuthParams.redirectUri}&code=${code}&state=${oAuthParams.state}`); } @@ -159,7 +160,7 @@ class LoginPage extends React.Component { } }); } else { - Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`); + Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}code=${code}&state=${oAuthParams.state}`); } // Util.showMessage("success", `Authorization code: ${res.data}`);