File tree 4 files changed +32
-5
lines changed
client/packages/lowcoder/src
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) => {
122
122
if ( ! notAuthRequiredPath ( error . config ?. url ) ) {
123
123
if ( error . response . status === API_STATUS_CODES . REQUEST_NOT_AUTHORISED ) {
124
124
// 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
+ }
126
133
// Redirect to login and set a redirect url.
127
134
StoreRegistry . getStore ( ) . dispatch (
128
135
logoutAction ( {
Original file line number Diff line number Diff line change @@ -150,7 +150,13 @@ export default function ProfileDropdown(props: DropDownProps) {
150
150
dispatch ( profileSettingModalVisible ( true ) ) ;
151
151
} else if ( e . key === "logout" ) {
152
152
// 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
+ } ) ) ;
154
160
} else if ( e . keyPath . includes ( "switchOrg" ) ) {
155
161
if ( e . key === "newOrganization" ) {
156
162
// create new organization
Original file line number Diff line number Diff line change @@ -155,6 +155,13 @@ export default function FormLoginSteps(props: FormLoginProps) {
155
155
setSigninEnabled ( LOWCODER_EMAIL_AUTH_ENABLED === 'true' ) ;
156
156
} , [ serverSettings ] ) ;
157
157
158
+ const afterLoginSuccess = ( ) => {
159
+ if ( props . organizationId ) {
160
+ localStorage . setItem ( "lowcoder_login_orgId" , props . organizationId ) ;
161
+ }
162
+ fetchUserAfterAuthSuccess ?.( ) ;
163
+ }
164
+
158
165
const { onSubmit, loading } = useAuthSubmit (
159
166
( ) =>
160
167
UserApi . formLogin ( {
@@ -168,7 +175,7 @@ export default function FormLoginSteps(props: FormLoginProps) {
168
175
} ) ,
169
176
false ,
170
177
redirectUrl ,
171
- fetchUserAfterAuthSuccess ,
178
+ afterLoginSuccess ,
172
179
) ;
173
180
174
181
const fetchOrgsByEmail = ( ) => {
@@ -274,7 +281,7 @@ export default function FormLoginSteps(props: FormLoginProps) {
274
281
< Divider />
275
282
< AuthBottomView >
276
283
< StyledRouteLink to = { {
277
- pathname : AUTH_REGISTER_URL ,
284
+ pathname : props . organizationId ? `/org/ ${ props . organizationId } /auth/register` : AUTH_REGISTER_URL ,
278
285
state : { ...location . state || { } , email : account }
279
286
} } >
280
287
{ trans ( "userAuth.register" ) }
Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ function UserRegister() {
86
86
} ;
87
87
} , [ serverSettings ] ) ;
88
88
89
+ const afterLoginSuccess = ( ) => {
90
+ if ( organizationId ) {
91
+ localStorage . setItem ( "lowcoder_login_orgId" , organizationId ) ;
92
+ }
93
+ fetchUserAfterAuthSuccess ?.( ) ;
94
+ }
95
+
89
96
const { loading, onSubmit } = useAuthSubmit (
90
97
( ) =>
91
98
UserApi . formLogin ( {
@@ -99,7 +106,7 @@ function UserRegister() {
99
106
} ) ,
100
107
false ,
101
108
redirectUrl ,
102
- fetchUserAfterAuthSuccess ,
109
+ afterLoginSuccess ,
103
110
) ;
104
111
105
112
const checkEmailExist = ( ) => {
You can’t perform that action at this time.
0 commit comments