File tree 4 files changed +44
-10
lines changed
client/packages/lowcoder/src
4 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,14 @@ import {
22
22
export type AuthInviteInfo = InviteInfo & { invitationId : string } ;
23
23
export type AuthLocationState = { inviteInfo ?: AuthInviteInfo ; thirdPartyAuthError ?: boolean } ;
24
24
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 ,
28
33
} ;
29
34
30
35
export type OauthRequestParam = {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { createContext, useState } from "react";
16
16
import { SystemConfig } from "constants/configConstants" ;
17
17
import {
18
18
AuthInviteInfo ,
19
+ AuthSearchParamsType ,
19
20
AuthSessionStoreParams ,
20
21
ThirdPartyAuthGoal ,
21
22
ThirdPartyAuthType ,
@@ -185,3 +186,21 @@ export const getRedirectUrl = (authType: ThirdPartyAuthType) => {
185
186
`${ window . location . origin } ${ authType === "CAS" ? CAS_AUTH_REDIRECT : OAUTH_REDIRECT } `
186
187
) ;
187
188
} ;
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";
23
23
import { messageInstance } from "lowcoder-design" ;
24
24
25
25
import { AuthSearchParams } from "constants/authConstants" ;
26
+ import { saveAuthSearchParams } from "pages/userAuth/authUtils" ;
26
27
27
28
function validResponseData ( response : AxiosResponse < ApiResponse > ) {
28
29
return response && response . data && response . data . data ;
@@ -133,13 +134,18 @@ export function* logoutSaga(action: LogoutActionType) {
133
134
let redirectURL = AUTH_LOGIN_URL ;
134
135
if ( action . payload . notAuthorised ) {
135
136
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)}`;
137
139
const urlObj = new URL ( currentUrl ) ;
138
140
// Add loginType param for auto login jump
139
141
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
+ } ) ;
143
149
}
144
150
let isValidResponse = true ;
145
151
if ( ! action . payload . notAuthorised ) {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { checkIsMobile } from "util/commonUtils";
16
16
import { EditorContext } from "comps/editorState" ;
17
17
import { getDataSourceStructures } from "redux/selectors/datasourceSelectors" ;
18
18
import { DatasourceStructure } from "api/datasourceApi" ;
19
+ import { loadAuthSearchParams } from "pages/userAuth/authUtils" ;
19
20
20
21
export const ForceViewModeContext = React . createContext < boolean > ( false ) ;
21
22
@@ -59,9 +60,12 @@ export function useApplicationId() {
59
60
}
60
61
61
62
export 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);
65
69
}
66
70
67
71
export function useFixedDelay ( callback : ( ) => Promise < unknown > , delay : number | null ) {
You can’t perform that action at this time.
0 commit comments