Use default theme-class for corrupt users.json file

where settings key is missing etc
Fixes Ui.UiServer Error 500: UiWSGIHandler error
This commit is contained in:
canewsin 2022-12-25 01:28:16 +05:30
parent 77b4297224
commit c354f9e24d
1 changed files with 4 additions and 1 deletions

View File

@ -749,7 +749,10 @@ class UiRequest(object):
def replaceHtmlVariables(self, block, path_parts):
user = self.getCurrentUser()
themeclass = "theme-%-6s" % re.sub("[^a-z]", "", user.settings.get("theme", "light"))
if user and user.settings:
themeclass = "theme-%-6s" % re.sub("[^a-z]", "", user.settings.get("theme", "light"))
else:
themeclass = "theme-light"
block = block.replace(b"{themeclass}", themeclass.encode("utf8"))
if path_parts: