|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Login Controller |
| 5 | + * |
| 6 | + * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | + * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | + * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | + * |
| 10 | + * @package phpMyFAQ |
| 11 | + * @author Thorsten Rinne <thorsten@phpmyfaq.de> |
| 12 | + * @copyright 2012-2026 phpMyFAQ Team |
| 13 | + * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | + * @link https://www.phpmyfaq.de |
| 15 | + * @since 2012-02-12 |
| 16 | + */ |
| 17 | + |
| 18 | +namespace phpMyFAQ\Controller\Frontend; |
| 19 | + |
| 20 | +use phpMyFAQ\Core\Exception; |
| 21 | +use phpMyFAQ\Translation; |
| 22 | +use Symfony\Component\HttpFoundation\Request; |
| 23 | +use Symfony\Component\HttpFoundation\Response; |
| 24 | +use Symfony\Component\Routing\Attribute\Route; |
| 25 | +use Twig\Error\LoaderError; |
| 26 | + |
| 27 | +final class LoginController extends AbstractFrontController |
| 28 | +{ |
| 29 | + /** |
| 30 | + * @throws Exception |
| 31 | + * @throws LoaderError |
| 32 | + * @throws \Exception |
| 33 | + */ #[Route(path: '/login', name: 'public.login')] |
| 34 | + public function index(Request $request): Response |
| 35 | + { |
| 36 | + $faqSession = $this->container->get('phpmyfaq.user.session'); |
| 37 | + $faqSession->setCurrentUser($this->currentUser); |
| 38 | + $faqSession->userTracking('login', 0); |
| 39 | + |
| 40 | + // @todo Implement login message and action handling |
| 41 | + // $loginMessage = ''; |
| 42 | + // if (!is_null($error)) { |
| 43 | + // $loginMessage = '<div class="alert alert-danger" role="alert">' . $error . '</div>'; |
| 44 | + // } |
| 45 | + // |
| 46 | + // $templateFile = './login.twig'; |
| 47 | + // if ($action == 'twofactor') { |
| 48 | + // $templateFile = './twofactor.twig'; |
| 49 | + // } |
| 50 | + |
| 51 | + return $this->render('login.twig', [ |
| 52 | + ...$this->getHeader($request), |
| 53 | + 'title' => sprintf('%s - %s', Translation::get(key: 'msgLoginUser'), $this->configuration->getTitle()), |
| 54 | + 'loginHeader' => Translation::get(key: 'msgLoginUser'), |
| 55 | + 'sendPassword' => Translation::get(key: 'lostPassword'), |
| 56 | + 'loginMessage' => '', //$loginMessage, |
| 57 | + 'writeLoginPath' => $this->configuration->getDefaultUrl(), |
| 58 | + 'faqloginaction' => '', //$action, |
| 59 | + 'login' => Translation::get(key: 'ad_auth_ok'), |
| 60 | + 'username' => Translation::get(key: 'ad_auth_user'), |
| 61 | + 'password' => Translation::get(key: 'ad_auth_passwd'), |
| 62 | + 'rememberMe' => Translation::get(key: 'rememberMe'), |
| 63 | + 'msgTwofactorEnabled' => Translation::get(key: 'msgTwofactorEnabled'), |
| 64 | + 'msgTwofactorTokenModelTitle' => Translation::get(key: 'msgTwofactorTokenModelTitle'), |
| 65 | + 'msgEnterTwofactorToken' => Translation::get(key: 'msgEnterTwofactorToken'), |
| 66 | + 'msgTwofactorCheck' => Translation::get(key: 'msgTwofactorCheck'), |
| 67 | + 'userid' => $this->currentUser->getUserId(), |
| 68 | + 'enableRegistration' => $this->configuration->get('security.enableRegistration'), |
| 69 | + 'registerUser' => Translation::get(key: 'msgRegistration'), |
| 70 | + 'useSignInWithMicrosoft' => $this->configuration->isSignInWithMicrosoftActive(), |
| 71 | + 'isWebAuthnEnabled' => $this->configuration->get('security.enableWebAuthnSupport'), |
| 72 | + ]); |
| 73 | + } |
| 74 | +} |
0 commit comments