Add more secret string fields (#10149)

This commit is contained in:
Joakim Sørensen 2021-10-04 17:42:18 +02:00 committed by GitHub
parent 13fe62975d
commit 784e5e6e39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,8 @@ import type {
HaFormStringSchema, HaFormStringSchema,
} from "./ha-form"; } from "./ha-form";
const MASKED_FIELDS = ["password", "secret", "token"];
@customElement("ha-form-string") @customElement("ha-form-string")
export class HaFormString extends LitElement implements HaFormElement { export class HaFormString extends LitElement implements HaFormElement {
@property() public schema!: HaFormStringSchema; @property() public schema!: HaFormStringSchema;
@ -33,7 +35,7 @@ export class HaFormString extends LitElement implements HaFormElement {
} }
protected render(): TemplateResult { protected render(): TemplateResult {
return this.schema.name.includes("password") return MASKED_FIELDS.some((field) => this.schema.name.includes(field))
? html` ? html`
<paper-input <paper-input
.type=${this._unmaskedPassword ? "text" : "password"} .type=${this._unmaskedPassword ? "text" : "password"}