Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae91db0

Browse files
refactor: handle redirectUrl using sessionStoragee
1 parent5dd8d32 commitae91db0

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

‎client/packages/lowcoder/src/constants/authConstants.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ import {
2222
exporttypeAuthInviteInfo=InviteInfo&{invitationId:string};
2323
exporttypeAuthLocationState={inviteInfo?:AuthInviteInfo;thirdPartyAuthError?:boolean};
2424

25-
exportconstAuthSearchParams={
26-
loginType:"loginType",
27-
redirectUrl:"redirectUrl",
25+
exportenumAuthSearchParams{
26+
loginType="loginType",
27+
redirectUrl="redirectUrl",
28+
};
29+
30+
exporttypeAuthSearchParamsType={
31+
loginType:string|null,
32+
redirectUrl:string|null,
2833
};
2934

3035
exporttypeOauthRequestParam={

‎client/packages/lowcoder/src/pages/userAuth/authUtils.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { createContext, useState } from "react";
1616
import{SystemConfig}from"constants/configConstants";
1717
import{
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+
constAuthSearchParamStorageKey="_temp_auth_search_params_";
191+
192+
exportconstsaveAuthSearchParams=(
193+
authSearchParams:AuthSearchParamsType
194+
)=>{
195+
sessionStorage.setItem(AuthSearchParamStorageKey,JSON.stringify(authSearchParams));
196+
}
197+
198+
exportconstloadAuthSearchParams=():AuthSearchParamsType|null=>{
199+
constauthParams=sessionStorage.getItem(AuthSearchParamStorageKey);
200+
if(!authParams)returnnull;
201+
returnJSON.parse(authParams);
202+
}
203+
204+
exportconstclearAuthSearchParams=()=>{
205+
sessionStorage.removeItem(AuthSearchParamStorageKey);
206+
}

‎client/packages/lowcoder/src/redux/sagas/userSagas.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { defaultUser } from "constants/userConstants";
2323
import{messageInstance}from"lowcoder-design";
2424

2525
import{AuthSearchParams}from"constants/authConstants";
26+
import{saveAuthSearchParams}from"pages/userAuth/authUtils";
2627

2728
functionvalidResponseData(response:AxiosResponse<ApiResponse>){
2829
returnresponse&&response.data&&response.data.data;
@@ -133,13 +134,18 @@ export function* logoutSaga(action: LogoutActionType) {
133134
letredirectURL=AUTH_LOGIN_URL;
134135
if(action.payload.notAuthorised){
135136
constcurrentUrl=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
consturlObj=newURL(currentUrl);
138140
// Add loginType param for auto login jump
139141
constloginType=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
letisValidResponse=true;
145151
if(!action.payload.notAuthorised){

‎client/packages/lowcoder/src/util/hooks.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { checkIsMobile } from "util/commonUtils";
1616
import{EditorContext}from"comps/editorState";
1717
import{getDataSourceStructures}from"redux/selectors/datasourceSelectors";
1818
import{DatasourceStructure}from"api/datasourceApi";
19+
import{loadAuthSearchParams}from"pages/userAuth/authUtils";
1920

2021
exportconstForceViewModeContext=React.createContext<boolean>(false);
2122

@@ -59,9 +60,12 @@ export function useApplicationId() {
5960
}
6061

6162
exportfunctionuseRedirectUrl(){
62-
constlocation=useLocation();
63-
constqueryParams=newURLSearchParams(location.search);
64-
returnqueryParams.get(AuthSearchParams.redirectUrl);
63+
constauthSearchParams=loadAuthSearchParams()
64+
constredirectUrl=authSearchParams&&authSearchParams.redirectUrl
65+
returnredirectUrl&&decodeURIComponent(redirectUrl);
66+
// const location = useLocation();
67+
// const queryParams = new URLSearchParams(location.search);
68+
// return queryParams.get(AuthSearchParams.redirectUrl);
6569
}
6670

6771
exportfunctionuseFixedDelay(callback:()=>Promise<unknown>,delay:number|null){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp