Skip to content

Commit d85e38e

Browse files
authored
Merge pull request #3941 from shesha-io/f/login-redirect-fix
fix: fixed handling of returnUrl after login
2 parents f5d9828 + 948b2b7 commit d85e38e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

shesha-reactjs/src/providers/auth/authenticator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ export class Authenticator implements IAuthenticator {
230230
const userProfile = await this.#fetchUserInfoHttp();
231231
this.#loginInfo = userProfile;
232232

233+
if (!userProfile.user)
234+
throw new Error(ERROR_MESSAGES.USER_PROFILE_IS_UNAVAILABLE);
235+
233236
this.#updateState('ready');
234237

235238
const redirectUrl = this.#getRedirectUrl(this.#router.fullPath, userProfile.user);

shesha-reactjs/src/providers/auth/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const ERROR_MESSAGES = {
2727
GENERIC: 'Oops, something went wrong',
2828
LOGIN: 'Failed to login',
2929
USER_PROFILE_LOADING: 'Failed to load user profile',
30+
USER_PROFILE_IS_UNAVAILABLE: 'User profile info is unavailable',
3031
};
3132

3233
export interface IAuthenticator {

shesha-reactjs/src/utils/url.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ export function removeURLParameter(url: string, parameter: string): string {
8989
if (!(parameter in parsed))
9090
return url;
9191
delete parsed[parameter];
92-
return baseUrl + '?' + qs.stringify(parsed);
92+
const newQueryString = qs.stringify(parsed);
93+
return isNullOrWhiteSpace(newQueryString)
94+
? baseUrl
95+
: baseUrl + '?' + newQueryString;
9396
}
9497

9598

0 commit comments

Comments
 (0)