mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-03 03:18:28 +02:00
dashboard: Small cleanups to dashboard (#5841)
This commit is contained in:
@@ -23,45 +23,45 @@ class DashboardSettings:
|
||||
self.cookie_secret: str | None = None
|
||||
self.absolute_config_dir: Path | None = None
|
||||
|
||||
def parse_args(self, args):
|
||||
def parse_args(self, args: Any) -> None:
|
||||
self.on_ha_addon: bool = args.ha_addon
|
||||
password: str = args.password or os.getenv("PASSWORD", "")
|
||||
password = args.password or os.getenv("PASSWORD") or ""
|
||||
if not self.on_ha_addon:
|
||||
self.username: str = args.username or os.getenv("USERNAME", "")
|
||||
self.username = args.username or os.getenv("USERNAME") or ""
|
||||
self.using_password = bool(password)
|
||||
if self.using_password:
|
||||
self.password_hash = password_hash(password)
|
||||
self.config_dir: str = args.configuration
|
||||
self.absolute_config_dir: Path = Path(self.config_dir).resolve()
|
||||
self.config_dir = args.configuration
|
||||
self.absolute_config_dir = Path(self.config_dir).resolve()
|
||||
CORE.config_path = os.path.join(self.config_dir, ".")
|
||||
|
||||
@property
|
||||
def relative_url(self):
|
||||
return os.getenv("ESPHOME_DASHBOARD_RELATIVE_URL", "/")
|
||||
def relative_url(self) -> str:
|
||||
return os.getenv("ESPHOME_DASHBOARD_RELATIVE_URL") or "/"
|
||||
|
||||
@property
|
||||
def status_use_ping(self):
|
||||
return get_bool_env("ESPHOME_DASHBOARD_USE_PING")
|
||||
|
||||
@property
|
||||
def status_use_mqtt(self):
|
||||
def status_use_mqtt(self) -> bool:
|
||||
return get_bool_env("ESPHOME_DASHBOARD_USE_MQTT")
|
||||
|
||||
@property
|
||||
def using_ha_addon_auth(self):
|
||||
def using_ha_addon_auth(self) -> bool:
|
||||
if not self.on_ha_addon:
|
||||
return False
|
||||
return not get_bool_env("DISABLE_HA_AUTHENTICATION")
|
||||
|
||||
@property
|
||||
def using_auth(self):
|
||||
def using_auth(self) -> bool:
|
||||
return self.using_password or self.using_ha_addon_auth
|
||||
|
||||
@property
|
||||
def streamer_mode(self):
|
||||
def streamer_mode(self) -> bool:
|
||||
return get_bool_env("ESPHOME_STREAMER_MODE")
|
||||
|
||||
def check_password(self, username, password):
|
||||
def check_password(self, username: str, password: str) -> bool:
|
||||
if not self.using_auth:
|
||||
return True
|
||||
if username != self.username:
|
||||
|
||||
Reference in New Issue
Block a user