From 837d45b633e46dc4831975578f3d95122a5a7552 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Wed, 11 Dec 2024 11:53:51 +0000 Subject: [PATCH] load login faq entries only if configuration has been set accordingly, fixes #4997 Closes #4997 Merge request studip/studip!3751 --- lib/phplib/Seminar_Auth.php | 16 ++++++++++------ templates/loginform.php | 9 +++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/phplib/Seminar_Auth.php b/lib/phplib/Seminar_Auth.php index 4ca21bf4dbd..4150df5fe2e 100644 --- a/lib/phplib/Seminar_Auth.php +++ b/lib/phplib/Seminar_Auth.php @@ -344,12 +344,16 @@ class Seminar_Auth if (isset($this->auth['uname']) && $this->error_msg) { PageLayout::postError(_('Bei der Anmeldung trat ein Fehler auf!'), $this->error_msg); } - $login_template->set_attribute('error_msg', $this->error_msg); - $login_template->set_attribute('uname', (isset($this->auth["uname"]) ? $this->auth["uname"] : Request::username('loginname'))); - $login_template->set_attribute('self_registration_activated', Config::get()->ENABLE_SELF_REGISTRATION); - $login_template->set_attribute('logout', Request::bool('logout', false)); - $login_template->set_attribute('faq_entries', LoginFaq::findBySQL("1")); - $login_template->set_attribute('news_entries', array_values($news_entries)); + $login_template->error_msg = $this->error_msg; + $login_template->uname = $this->auth['uname'] ?? Request::username('loginname'); + $login_template->self_registration_activated = Config::get()->ENABLE_SELF_REGISTRATION; + $login_template->logout = Request::bool('logout', false); + $login_template->faq_entries = []; + $login_template->news_entries = array_values($news_entries); + + if (Config::get()->getValue('LOGIN_FAQ_VISIBILITY')) { + $login_template->faq_entries = LoginFaq::findBySQL('1'); + } } PageLayout::setHelpKeyword('Basis.AnmeldungLogin'); $header_template = $GLOBALS['template_factory']->open('header'); diff --git a/templates/loginform.php b/templates/loginform.php index 2274032a657..ef831d98cda 100644 --- a/templates/loginform.php +++ b/templates/loginform.php @@ -2,6 +2,7 @@ /** * @var array $loginerror * @var string $error_msg + * @var LoginFaq[] $faq_entries */ // Get background images (this should be resolved differently since mobile @@ -25,7 +26,7 @@ if (!match_route('web_migrate.php')) { } $show_login = !(current(StudipAuthAbstract::getInstance()) instanceof StudipAuthSSO) && StudipAuthAbstract::isLoginEnabled(); $show_hidden_login = !$show_login && StudipAuthAbstract::isLoginEnabled(); -$enable_faq = Config::get()->LOGIN_FAQ_VISIBILITY && count($faq_entries) > 0; +$enable_faq = count($faq_entries) > 0; $enable_news = Config::get()->LOGIN_NEWS_VISIBILITY && count($news_entries) > 0; ?> <main id="content" class="loginpage"> @@ -103,7 +104,7 @@ $enable_news = Config::get()->LOGIN_NEWS_VISIBILITY && count($news_entries) > 0; <button id="show-faq" title="<?= _('Hinweise zum Login anzeigen')?>"> <?= Icon::create('faq')->asImg(24, ['style' => 'align-self: end;']) ?> </button> - + </div> <? endif; ?> <? if ($enable_faq): ?> @@ -148,7 +149,7 @@ $enable_news = Config::get()->LOGIN_NEWS_VISIBILITY && count($news_entries) > 0; faqButton.classList.add('selected'); newsButton.classList.remove('selected'); }); - + newsButton.addEventListener('click', e => { const faqBox = document.getElementById('login-faq-box'); const newsBox = document.getElementById('login-news-box'); @@ -159,4 +160,4 @@ $enable_news = Config::get()->LOGIN_NEWS_VISIBILITY && count($news_entries) > 0; }); <? endif ?> -</script> \ No newline at end of file +</script> -- GitLab