diff --git a/src/auth/ha-auth-flow.ts b/src/auth/ha-auth-flow.ts index 00070a57b664..fb1d7d7c32f5 100644 --- a/src/auth/ha-auth-flow.ts +++ b/src/auth/ha-auth-flow.ts @@ -21,7 +21,6 @@ import { DataEntryFlowStepForm, } from "../data/data_entry_flow"; import "./ha-auth-form"; -import { fireEvent } from "../common/dom/fire_event"; type State = "loading" | "error" | "step"; @@ -39,7 +38,9 @@ export class HaAuthFlow extends LitElement { @property({ attribute: false }) public step?: DataEntryFlowStep; - @property({ type: Boolean }) private storeToken = false; + @property({ type: Boolean }) private initStoreToken = false; + + @state() private _storeToken = false; @state() private _state: State = "loading"; @@ -56,6 +57,10 @@ export class HaAuthFlow extends LitElement { willUpdate(changedProps: PropertyValues) { super.willUpdate(changedProps); + if (!this.hasUpdated) { + this._storeToken = this.initStoreToken; + } + if (!changedProps.has("step")) { return; } @@ -155,11 +160,6 @@ export class HaAuthFlow extends LitElement { } private _renderForm() { - const showBack = - this.step?.type === "form" && - this.authProvider?.users && - !["select_mfa_module", "mfa"].includes(this.step.step_id); - switch (this._state) { case "step": if (this.step == null) { @@ -168,12 +168,7 @@ export class HaAuthFlow extends LitElement { return html` ${this._renderStep(this.step)} -
- ${showBack - ? html` - ${this.localize("ui.panel.page-authorize.form.previous")} - ` - : nothing} +
${this._computeStepDescription(step)} @@ -269,7 +264,7 @@ export class HaAuthFlow extends LitElement { } private _storeTokenChanged(e: CustomEvent) { - this.storeToken = (e.currentTarget as HTMLInputElement).checked; + this._storeToken = (e.currentTarget as HTMLInputElement).checked; } private async _providerChanged(newProvider?: AuthProvider) { @@ -303,7 +298,7 @@ export class HaAuthFlow extends LitElement { this.redirectUri!, data.result, this.oauth2State, - this.storeToken + this._storeToken ); return; } @@ -385,7 +380,7 @@ export class HaAuthFlow extends LitElement { this.redirectUri!, newStep.result, this.oauth2State, - this.storeToken + this._storeToken ); return; } @@ -400,10 +395,6 @@ export class HaAuthFlow extends LitElement { this._submitting = false; } } - - private _localFlow() { - fireEvent(this, "default-login-flow", { value: false }); - } } declare global { diff --git a/src/auth/ha-authorize.ts b/src/auth/ha-authorize.ts index 97fc3ef4790d..74b1e649d179 100644 --- a/src/auth/ha-authorize.ts +++ b/src/auth/ha-authorize.ts @@ -13,7 +13,6 @@ import { import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin"; import { registerServiceWorker } from "../util/register-service-worker"; import "./ha-auth-flow"; -import "./ha-local-auth-flow"; import("./ha-pick-auth-provider"); @@ -36,12 +35,12 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { @state() private _authProviders?: AuthProvider[]; + @state() private _preselectStoreToken = false; + @state() private _ownInstance = false; @state() private _error?: string; - @state() private _forceDefaultLogin = false; - constructor() { super(); const query = extractSearchParamsObject() as AuthUrlSearchParams; @@ -84,8 +83,7 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { display: block; margin-top: 24px; } - ha-auth-flow, - ha-local-auth-flow { + ha-auth-flow { display: flex; justify-content: center; flex-direction: column; @@ -176,44 +174,29 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { ` : nothing} -
+
${!this._authProvider ? html`

${this.localize("ui.panel.page-authorize.initializing")}

` - : !this._forceDefaultLogin && - this._authProvider!.users && - this.clientId != null && - this.redirectUri != null - ? html`` - : html` - ${inactiveProviders!.length > 0 - ? html` - - ` - : ""}`} + .initStoreToken=${this._preselectStoreToken} + > + ${inactiveProviders!.length > 0 + ? html` + + ` + : ""}`}