From d7ec19d8294a896437c2dd26711952f72bb9ab8e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 8 Jul 2025 15:01:45 +0200 Subject: [PATCH] StyleSheet: Do not rely on config to trigger auth fixes #5385 (cherry picked from commit 5d71d09e548e048e8b275afc203cfa1bc2707ba8) --- library/Icinga/Web/StyleSheet.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 65cbb9705..86b357835 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -139,6 +139,7 @@ class StyleSheet $this->lessCompiler->addLessFile($this->pubPath . '/' . $lessFile); } + $auth = Auth::getInstance(); $mm = $this->app->getModuleManager(); foreach ($mm->getLoadedModules() as $moduleName => $module) { @@ -157,7 +158,6 @@ class StyleSheet } if (! (bool) $themingConfig->get('disabled', false)) { - $auth = Auth::getInstance(); if ($auth->isAuthenticated()) { $userTheme = $auth->getUser()->getPreferences()->getValue('icingaweb', 'theme'); if ($userTheme !== null) { @@ -174,7 +174,7 @@ class StyleSheet Logger::warning(sprintf( 'Theme "%s" set by user "%s" has not been found.', $theme, - ($user = Auth::getInstance()->getUser()) !== null ? $user->getUsername() : 'anonymous' + $auth->isAuthenticated() ? $auth->getUser()->getUsername() : 'anonymous' )); } } @@ -184,10 +184,10 @@ class StyleSheet } $mode = 'none'; - if ($user = Auth::getInstance()->getUser()) { + if ($auth->isAuthenticated()) { $file = $themePath !== null ? @file_get_contents($themePath) : false; if (! $file || strpos($file, self::LIGHT_MODE_IDENTIFIER) !== false) { - $mode = $user->getPreferences()->getValue('icingaweb', 'theme_mode', self::DEFAULT_MODE); + $mode = $auth->getUser()->getPreferences()->getValue('icingaweb', 'theme_mode', self::DEFAULT_MODE); } }