diff --git a/src/auth/FormElement.ts b/src/auth/FormElement.ts index 6b86f5a4dffa..e4b5b1c98b82 100644 --- a/src/auth/FormElement.ts +++ b/src/auth/FormElement.ts @@ -54,11 +54,15 @@ export default class GmfAuthForm extends GmfBaseElement { @state() private allowPasswordReset = false; @state() private changingPassword = false; @state() private userMustChangeItsPassword = false; + @state() private openIdConnectUrl = ''; @state() private error = false; @state() private otpImage = ''; @state() private gmfUser: User = null; @state() private customCSS_ = ''; private changingPasswordUsername_ = ''; + private initialApplicationUrl = window.location.href; + private currentApplicationUrl = window.location.href; + private openIdConnectBaseUrl = ''; connectedCallback(): void { super.connectedCallback(); @@ -79,6 +83,16 @@ export default class GmfAuthForm extends GmfBaseElement { this.loginInfoMessage = message; }, }), + setInterval(() => { + this.currentApplicationUrl = window.location.href; + const applicationUrl = this.loginInfoMessage + ? this.currentApplicationUrl + : this.initialApplicationUrl; + const params = new URLSearchParams({ + came_from: applicationUrl, + }); + this.openIdConnectUrl = `${this.openIdConnectBaseUrl}?${params.toString()}`; + }, 200), ); // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion @@ -103,6 +117,7 @@ export default class GmfAuthForm extends GmfBaseElement { this.twoFactorAuth = configuration.gmfTwoFactorAuth; this.allowPasswordChange = configuration.gmfAuthenticationConfig.allowPasswordChange; this.allowPasswordReset = configuration.gmfAuthenticationConfig.allowPasswordReset; + this.openIdConnectBaseUrl = configuration.gmfOidcLoginUrl; if (configuration.gmfCustomCSS && configuration.gmfCustomCSS.authentication !== undefined) { this.customCSS_ = configuration.gmfCustomCSS.authentication; } @@ -168,7 +183,7 @@ export default class GmfAuthForm extends GmfBaseElement {