From 3a878baac812958fd27ca5d82ef4bb4463de4654 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Sat, 26 Mar 2022 00:54:16 +0300 Subject: hide logout botton when auth is disabled --- kvmd/apps/kvmd/info/__init__.py | 2 ++ kvmd/apps/kvmd/info/auth.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 kvmd/apps/kvmd/info/auth.py (limited to 'kvmd') diff --git a/kvmd/apps/kvmd/info/__init__.py b/kvmd/apps/kvmd/info/__init__.py index 53a02f88..f8871d72 100644 --- a/kvmd/apps/kvmd/info/__init__.py +++ b/kvmd/apps/kvmd/info/__init__.py @@ -25,6 +25,7 @@ from typing import Set from ....yamlconf import Section from .base import BaseInfoSubmanager +from .auth import AuthInfoSubmanager from .system import SystemInfoSubmanager from .meta import MetaInfoSubmanager from .extras import ExtrasInfoSubmanager @@ -37,6 +38,7 @@ class InfoManager: def __init__(self, config: Section) -> None: self.__subs = { "system": SystemInfoSubmanager(config.kvmd.streamer.cmd), + "auth": AuthInfoSubmanager(config.kvmd.auth.enabled), "meta": MetaInfoSubmanager(config.kvmd.info.meta), "extras": ExtrasInfoSubmanager(config), "hw": HwInfoSubmanager(**config.kvmd.info.hw._unpack()), diff --git a/kvmd/apps/kvmd/info/auth.py b/kvmd/apps/kvmd/info/auth.py new file mode 100644 index 00000000..bf1c6160 --- /dev/null +++ b/kvmd/apps/kvmd/info/auth.py @@ -0,0 +1,34 @@ +# ========================================================================== # +# # +# KVMD - The main PiKVM daemon. # +# # +# Copyright (C) 2018-2022 Maxim Devaev # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# ========================================================================== # + + +from typing import Dict + +from .base import BaseInfoSubmanager + + +# ===== +class AuthInfoSubmanager(BaseInfoSubmanager): + def __init__(self, enabled: bool) -> None: + self.__enabled = enabled + + async def get_state(self) -> Dict: + return {"enabled": self.__enabled} -- cgit v1.2.3