From af2250835a124a2e852746dde0c28f426e0ab568 Mon Sep 17 00:00:00 2001 From: Donnie Date: Tue, 20 Oct 2020 13:24:48 -0700 Subject: [PATCH] Only admins can launch quick bar (#7388) Co-authored-by: Zack Barett --- src/state/quick-bar-mixin.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/state/quick-bar-mixin.ts b/src/state/quick-bar-mixin.ts index 1aa198ac8e..cfefcb388c 100644 --- a/src/state/quick-bar-mixin.ts +++ b/src/state/quick-bar-mixin.ts @@ -18,7 +18,14 @@ export default >(superClass: T) => protected firstUpdated(changedProps: PropertyValues) { super.firstUpdated(changedProps); + this._registerShortcut(); + } + + private _registerShortcut() { document.addEventListener("keydown", (e: KeyboardEvent) => { + if (!this.hass?.user?.is_admin) { + return; + } if (this.isOSCtrlKey(e) && e.code === "KeyP") { e.preventDefault(); const eventParams: QuickBarParams = {};