diff --git a/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts b/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts index 5e1e385e08..6900aebcb6 100644 --- a/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts @@ -62,21 +62,36 @@ export class UmbAppElement extends UmbLitElement { path: 'oauth_complete', component: () => import('./app-error.element.js'), setup: (component) => { + if (!this.#authContext) { + throw new Error('[Fatal] Auth context is not available'); + } + const searchParams = new URLSearchParams(window.location.search); const hasCode = searchParams.has('code'); (component as UmbAppErrorElement).hideBackButton = true; (component as UmbAppErrorElement).errorHeadline = this.localize.term('general_login'); - (component as UmbAppErrorElement).errorMessage = hasCode - ? this.localize.term('errors_externalLoginSuccess') - : this.localize.term('errors_externalLoginFailed'); - // Complete the authorization request - this.#authContext?.completeAuthorizationRequest().finally(() => { - // If we don't have an opener, redirect to the root - if (!window.opener) { - history.replaceState(null, '', ''); - } - }); + // If there is an opener, we are in a popup window, and we should show a different message + // than if we are in the main window. If we are in the main window, we should redirect to the root. + // The authorization request will be completed in the active window (main or popup) and the authorization signal will be sent. + // If we are in a popup window, the storage event in UmbAuthContext will catch the signal and close the window. + // If we are in the main window, the signal will be caught right here and the user will be redirected to the root. + if (window.opener) { + (component as UmbAppErrorElement).errorMessage = hasCode + ? this.localize.term('errors_externalLoginSuccess') + : this.localize.term('errors_externalLoginFailed'); + } else { + (component as UmbAppErrorElement).errorMessage = hasCode + ? this.localize.term('errors_externalLoginRedirectSuccess') + : this.localize.term('errors_externalLoginFailed'); + + this.observe(this.#authContext.authorizationSignal, () => { + window.location.href = '/'; + }); + } + + // Complete the authorization request, which will send the authorization signal + this.#authContext.completeAuthorizationRequest(); }, }, { diff --git a/src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts b/src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts index b2dcc78cd8..fa0a3caba6 100644 --- a/src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts +++ b/src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts @@ -711,6 +711,7 @@ export default { externalLoginFailed: 'Serveren mislykkedes i at logge ind med den eksterne loginudbyder. Luk dette vindue og prøv igen.', externalLoginSuccess: 'Du er nu logget ind. Du kan nu lukke dette vindue.', + externalLoginRedirectSuccess: 'Du er nu logget ind. Du vil blive omdirigeret om et øjeblik.', }, openidErrors: { accessDenied: 'Access denied', diff --git a/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts b/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts index 7a039d433e..3d347d786a 100644 --- a/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts +++ b/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts @@ -720,6 +720,7 @@ export default { externalLoginFailed: 'The server failed to authorize you against the external login provider. Please close the window and try again.', externalLoginSuccess: 'You have successfully logged in. You may now close this window.', + externalLoginRedirectSuccess: 'You have successfully logged in. You will be redirected shortly.', }, openidErrors: { accessDenied: 'Access denied', diff --git a/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts b/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts index 388571673a..c179b8af63 100644 --- a/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts +++ b/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts @@ -731,6 +731,7 @@ export default { externalLoginFailed: 'The server failed to authorize you against the external login provider. Please close the window and try again.', externalLoginSuccess: 'You have successfully logged in. You may now close this window.', + externalLoginRedirectSuccess: 'You have successfully logged in. You will be redirected shortly.', }, openidErrors: { accessDenied: 'Access denied', diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-app-auth-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-app-auth-modal.element.ts index d652b7b065..98d3934121 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-app-auth-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-app-auth-modal.element.ts @@ -95,14 +95,16 @@ export class UmbAppAuthModalElement extends UmbModalBaseElement