File tree Expand file tree Collapse file tree 4 files changed +32
-5
lines changed
client/packages/lowcoder/src Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,14 @@ export const apiFailureResponseInterceptor = (error: any) => {
122122 if ( ! notAuthRequiredPath ( error . config ?. url ) ) {
123123 if ( error . response . status === API_STATUS_CODES . REQUEST_NOT_AUTHORISED ) {
124124 // get x-org-id from failed request
125- const organizationId = error . response . headers [ 'x-org-id' ] || undefined ;
125+ let organizationId ;
126+ if ( error . response . headers [ 'x-org-id' ] ) {
127+ organizationId = error . response . headers [ 'x-org-id' ] ;
128+ }
129+ if ( localStorage . getItem ( 'lowcoder_login_orgId' ) ) {
130+ organizationId = localStorage . getItem ( 'lowcoder_login_orgId' ) ;
131+ localStorage . removeItem ( 'lowcoder_login_orgId' ) ;
132+ }
126133 // Redirect to login and set a redirect url.
127134 StoreRegistry . getStore ( ) . dispatch (
128135 logoutAction ( {
Original file line number Diff line number Diff line change @@ -150,7 +150,13 @@ export default function ProfileDropdown(props: DropDownProps) {
150150 dispatch ( profileSettingModalVisible ( true ) ) ;
151151 } else if ( e . key === "logout" ) {
152152 // logout
153- dispatch ( logoutAction ( { } ) ) ;
153+ const organizationId = localStorage . getItem ( 'lowcoder_login_orgId' ) ;
154+ if ( organizationId ) {
155+ localStorage . removeItem ( 'lowcoder_login_orgId' ) ;
156+ }
157+ dispatch ( logoutAction ( {
158+ organizationId : organizationId || undefined ,
159+ } ) ) ;
154160 } else if ( e . keyPath . includes ( "switchOrg" ) ) {
155161 if ( e . key === "newOrganization" ) {
156162 // create new organization
Original file line number Diff line number Diff line change @@ -155,6 +155,13 @@ export default function FormLoginSteps(props: FormLoginProps) {
155155 setSigninEnabled ( LOWCODER_EMAIL_AUTH_ENABLED === 'true' ) ;
156156 } , [ serverSettings ] ) ;
157157
158+ const afterLoginSuccess = ( ) => {
159+ if ( props . organizationId ) {
160+ localStorage . setItem ( "lowcoder_login_orgId" , props . organizationId ) ;
161+ }
162+ fetchUserAfterAuthSuccess ?.( ) ;
163+ }
164+
158165 const { onSubmit, loading } = useAuthSubmit (
159166 ( ) =>
160167 UserApi . formLogin ( {
@@ -168,7 +175,7 @@ export default function FormLoginSteps(props: FormLoginProps) {
168175 } ) ,
169176 false ,
170177 redirectUrl ,
171- fetchUserAfterAuthSuccess ,
178+ afterLoginSuccess ,
172179 ) ;
173180
174181 const fetchOrgsByEmail = ( ) => {
@@ -274,7 +281,7 @@ export default function FormLoginSteps(props: FormLoginProps) {
274281 < Divider />
275282 < AuthBottomView >
276283 < StyledRouteLink to = { {
277- pathname : AUTH_REGISTER_URL ,
284+ pathname : props . organizationId ? `/org/ ${ props . organizationId } /auth/register` : AUTH_REGISTER_URL ,
278285 state : { ...location . state || { } , email : account }
279286 } } >
280287 { trans ( "userAuth.register" ) }
Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ function UserRegister() {
8686 } ;
8787 } , [ serverSettings ] ) ;
8888
89+ const afterLoginSuccess = ( ) => {
90+ if ( organizationId ) {
91+ localStorage . setItem ( "lowcoder_login_orgId" , organizationId ) ;
92+ }
93+ fetchUserAfterAuthSuccess ?.( ) ;
94+ }
95+
8996 const { loading, onSubmit } = useAuthSubmit (
9097 ( ) =>
9198 UserApi . formLogin ( {
@@ -99,7 +106,7 @@ function UserRegister() {
99106 } ) ,
100107 false ,
101108 redirectUrl ,
102- fetchUserAfterAuthSuccess ,
109+ afterLoginSuccess ,
103110 ) ;
104111
105112 const checkEmailExist = ( ) => {
You can’t perform that action at this time.
0 commit comments