From 33afc52a0bb91d6999723cdbf62705ca4826229b Mon Sep 17 00:00:00 2001 From: DacongDA Date: Fri, 23 May 2025 07:15:53 +0800 Subject: [PATCH] feat: can redirect user to login page after linking provider in prompt page (#3820) --- web/src/auth/AuthCallback.js | 6 +++++- web/src/auth/PromptPage.js | 4 +++- web/src/auth/SignupPage.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/web/src/auth/AuthCallback.js b/web/src/auth/AuthCallback.js index a3b53b3c..2bafe5ae 100644 --- a/web/src/auth/AuthCallback.js +++ b/web/src/auth/AuthCallback.js @@ -193,7 +193,11 @@ class AuthCallback extends React.Component { const token = res.data; Setting.goToLink(`${oAuthParams.redirectUri}${concatChar}${responseType}=${token}&state=${oAuthParams.state}&token_type=bearer`); } else if (responseType === "link") { - const from = innerParams.get("from"); + let from = innerParams.get("from"); + const oauth = innerParams.get("oauth"); + if (oauth) { + from += `?oauth=${oauth}`; + } Setting.goToLinkSoftOrJumpSelf(this, from); } else if (responseType === "saml") { if (res.data2.method === "POST") { diff --git a/web/src/auth/PromptPage.js b/web/src/auth/PromptPage.js index 919520a9..4c376242 100644 --- a/web/src/auth/PromptPage.js +++ b/web/src/auth/PromptPage.js @@ -194,8 +194,10 @@ class PromptPage extends React.Component { const redirectUri = params.get("redirectUri"); const code = params.get("code"); const state = params.get("state"); + const oauth = params.get("oauth"); if (redirectUri === null || code === null || state === null) { - return ""; + const signInUrl = sessionStorage.getItem("signinUrl"); + return oauth === "true" ? signInUrl : ""; } return `${redirectUri}?code=${code}&state=${state}`; } diff --git a/web/src/auth/SignupPage.js b/web/src/auth/SignupPage.js index 3103d8ef..4b6e41c6 100644 --- a/web/src/auth/SignupPage.js +++ b/web/src/auth/SignupPage.js @@ -195,8 +195,9 @@ class SignupPage extends React.Component { if (authConfig.appName === application.name) { return "/result"; } else { + const oAuthParams = Util.getOAuthGetParameters(); if (Setting.hasPromptPage(application)) { - return `/prompt/${application.name}`; + return `/prompt/${application.name}?oauth=${oAuthParams !== null}`; } else { return `/result/${application.name}`; }