diff --git a/src/auth/ha-authorize.ts b/src/auth/ha-authorize.ts
index 91fed8ef07..19e760f9d1 100644
--- a/src/auth/ha-authorize.ts
+++ b/src/auth/ha-authorize.ts
@@ -1,8 +1,16 @@
-import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
+import {
+ css,
+ CSSResultGroup,
+ html,
+ LitElement,
+ nothing,
+ PropertyValues,
+} from "lit";
import { customElement, property, state } from "lit/decorators";
import punycode from "punycode";
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
import { extractSearchParamsObject } from "../common/url/search-params";
+import "../components/ha-alert";
import {
AuthProvider,
AuthUrlSearchParams,
@@ -14,6 +22,11 @@ import "./ha-auth-flow";
import("./ha-pick-auth-provider");
+const appNames = {
+ "https://home-assistant.io/iOS": "iOS",
+ "https://home-assistant.io/android": "Android",
+};
+
@customElement("ha-authorize")
export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
@property() public clientId?: string;
@@ -26,6 +39,10 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
@state() private _authProviders?: AuthProvider[];
+ @state() private _ownInstance = false;
+
+ @state() private _error?: string;
+
constructor() {
super();
this.translationFragment = "page-authorize";
@@ -42,39 +59,47 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
}
protected render() {
+ if (this._error) {
+ return html`
${this.localize("ui.panel.page-authorize.initializing")}
`; } - // We don't have a good approach yet to map text markup in localization. - // So we sanitize the translation with innerText and then inject - // the name with a bold tag. - const loggingInWith = document.createElement("div"); - loggingInWith.innerText = this.localize( - "ui.panel.page-authorize.logging_in_with", - "authProviderName", - "NAME" - ); - loggingInWith.innerHTML = loggingInWith.innerHTML.replace( - "**NAME**", - `${this._authProvider!.name}` - ); - const inactiveProviders = this._authProviders.filter( (prv) => prv !== this._authProvider ); + const app = this.clientId && this.clientId in appNames; + return html` -- ${this.localize( - "ui.panel.page-authorize.authorizing_client", - "clientId", - this.clientId ? punycode.toASCII(this.clientId) : this.clientId - )} -
- ${loggingInWith} + ${!this._ownInstance + ? html`${this.localize("ui.panel.page-authorize.authorizing")}
`} + ${inactiveProviders.length > 0 + ? html`+ ${this.localize("ui.panel.page-authorize.logging_in_with", { + authProviderName: html`${this._authProvider!.name}`, + })} +
` + : nothing}