Skip to content

Commit b193288

Browse files
committed
save the "redirect after login" value as early as possible to prevent the router from overwriting it
1 parent 8578a2c commit b193288

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/apps/app/app-auth.controller.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { UMB_AUTH_CONTEXT, UMB_MODAL_APP_AUTH, type UmbUserLoginState } from '@umbraco-cms/backoffice/auth';
1+
import {
2+
UMB_AUTH_CONTEXT,
3+
UMB_MODAL_APP_AUTH,
4+
UMB_STORAGE_REDIRECT_URL,
5+
type UmbUserLoginState,
6+
} from '@umbraco-cms/backoffice/auth';
27
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
38
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
49
import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs';
@@ -65,6 +70,9 @@ export class UmbAppAuthController extends UmbControllerBase {
6570
throw new Error('[Fatal] Auth context is not available');
6671
}
6772

73+
// Save the current state
74+
sessionStorage.setItem(UMB_STORAGE_REDIRECT_URL, window.location.href);
75+
6876
// Figure out which providers are available
6977
const availableProviders = await firstValueFrom(this.#authContext.getAuthProviders(umbExtensionsRegistry));
7078

src/packages/core/auth/auth.context.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { UmbBackofficeExtensionRegistry, ManifestAuthProvider } from '../extension-registry/index.js';
22
import { UmbAuthFlow } from './auth-flow.js';
3-
import { UMB_AUTH_CONTEXT, UMB_STORAGE_REDIRECT_URL, UMB_STORAGE_TOKEN_RESPONSE_NAME } from './auth.context.token.js';
3+
import { UMB_AUTH_CONTEXT, UMB_STORAGE_TOKEN_RESPONSE_NAME } from './auth.context.token.js';
44
import type { UmbOpenApiConfiguration } from './models/openApiConfiguration.js';
55
import { OpenAPI } from '@umbraco-cms/backoffice/external/backend-api';
66
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -106,9 +106,6 @@ export class UmbAuthContext extends UmbContextBase<UmbAuthContext> {
106106
) {
107107
const redirectUrl = await this.#authFlow.makeAuthorizationRequest(identityProvider, usernameHint);
108108
if (redirect) {
109-
// Save the current state
110-
sessionStorage.setItem(UMB_STORAGE_REDIRECT_URL, window.location.href);
111-
112109
location.href = redirectUrl;
113110
return;
114111
}

0 commit comments

Comments
 (0)