File tree Expand file tree Collapse file tree 4 files changed +44
-10
lines changed
client/packages/lowcoder/src Expand file tree Collapse file tree 4 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,14 @@ import {
2222export type AuthInviteInfo = InviteInfo & { invitationId : string } ;
2323export type AuthLocationState = { inviteInfo ?: AuthInviteInfo ; thirdPartyAuthError ?: boolean } ;
2424
25- export const AuthSearchParams = {
26- loginType : "loginType" ,
27- redirectUrl : "redirectUrl" ,
25+ export enum AuthSearchParams {
26+ loginType = "loginType" ,
27+ redirectUrl = "redirectUrl" ,
28+ } ;
29+
30+ export type AuthSearchParamsType = {
31+ loginType : string | null ,
32+ redirectUrl : string | null ,
2833} ;
2934
3035export type OauthRequestParam = {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { createContext, useState } from "react";
1616import { SystemConfig } from "constants/configConstants" ;
1717import {
1818 AuthInviteInfo ,
19+ AuthSearchParamsType ,
1920 AuthSessionStoreParams ,
2021 ThirdPartyAuthGoal ,
2122 ThirdPartyAuthType ,
@@ -185,3 +186,21 @@ export const getRedirectUrl = (authType: ThirdPartyAuthType) => {
185186 `${ window . location . origin } ${ authType === "CAS" ? CAS_AUTH_REDIRECT : OAUTH_REDIRECT } `
186187 ) ;
187188} ;
189+
190+ const AuthSearchParamStorageKey = "_temp_auth_search_params_" ;
191+
192+ export const saveAuthSearchParams = (
193+ authSearchParams : AuthSearchParamsType
194+ ) => {
195+ sessionStorage . setItem ( AuthSearchParamStorageKey , JSON . stringify ( authSearchParams ) ) ;
196+ }
197+
198+ export const loadAuthSearchParams = ( ) :AuthSearchParamsType | null => {
199+ const authParams = sessionStorage . getItem ( AuthSearchParamStorageKey ) ;
200+ if ( ! authParams ) return null ;
201+ return JSON . parse ( authParams ) ;
202+ }
203+
204+ export const clearAuthSearchParams = ( ) => {
205+ sessionStorage . removeItem ( AuthSearchParamStorageKey ) ;
206+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { defaultUser } from "constants/userConstants";
2323import { messageInstance } from "lowcoder-design" ;
2424
2525import { AuthSearchParams } from "constants/authConstants" ;
26+ import { saveAuthSearchParams } from "pages/userAuth/authUtils" ;
2627
2728function validResponseData ( response : AxiosResponse < ApiResponse > ) {
2829 return response && response . data && response . data . data ;
@@ -133,13 +134,18 @@ export function* logoutSaga(action: LogoutActionType) {
133134 let redirectURL = AUTH_LOGIN_URL ;
134135 if ( action . payload . notAuthorised ) {
135136 const currentUrl = window . location . href ;
136- redirectURL = `${ AUTH_LOGIN_URL } ?redirectUrl=${ encodeURIComponent ( currentUrl ) } ` ;
137+ // redirectURL = `${AUTH_LOGIN_URL}`;
138+ // redirectURL = `${AUTH_LOGIN_URL}?redirectUrl=${encodeURIComponent(currentUrl)}`;
137139 const urlObj = new URL ( currentUrl ) ;
138140 // Add loginType param for auto login jump
139141 const loginType = urlObj . searchParams . get ( AuthSearchParams . loginType ) ;
140- if ( loginType ) {
141- redirectURL = redirectURL + `&${ AuthSearchParams . loginType } =${ loginType } ` ;
142- }
142+ // if (loginType) {
143+ // redirectURL = redirectURL + `&${AuthSearchParams.loginType}=${loginType}`;
144+ // }
145+ saveAuthSearchParams ( {
146+ [ AuthSearchParams . redirectUrl ] : encodeURIComponent ( currentUrl ) ,
147+ [ AuthSearchParams . loginType ] : loginType
148+ } ) ;
143149 }
144150 let isValidResponse = true ;
145151 if ( ! action . payload . notAuthorised ) {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { checkIsMobile } from "util/commonUtils";
1616import { EditorContext } from "comps/editorState" ;
1717import { getDataSourceStructures } from "redux/selectors/datasourceSelectors" ;
1818import { DatasourceStructure } from "api/datasourceApi" ;
19+ import { loadAuthSearchParams } from "pages/userAuth/authUtils" ;
1920
2021export const ForceViewModeContext = React . createContext < boolean > ( false ) ;
2122
@@ -59,9 +60,12 @@ export function useApplicationId() {
5960}
6061
6162export function useRedirectUrl ( ) {
62- const location = useLocation ( ) ;
63- const queryParams = new URLSearchParams ( location . search ) ;
64- return queryParams . get ( AuthSearchParams . redirectUrl ) ;
63+ const authSearchParams = loadAuthSearchParams ( )
64+ const redirectUrl = authSearchParams && authSearchParams . redirectUrl
65+ return redirectUrl && decodeURIComponent ( redirectUrl ) ;
66+ // const location = useLocation();
67+ // const queryParams = new URLSearchParams(location.search);
68+ // return queryParams.get(AuthSearchParams.redirectUrl);
6569}
6670
6771export function useFixedDelay ( callback : ( ) => Promise < unknown > , delay : number | null ) {
You can’t perform that action at this time.
0 commit comments