Skip to content

Commit 2195ee6

Browse files
committed
refactor: migrated login page (#3834)
1 parent c1ee9d1 commit 2195ee6

File tree

6 files changed

+83
-74
lines changed

6 files changed

+83
-74
lines changed

phpmyfaq/login.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

phpmyfaq/src/phpMyFAQ/Controller/Frontend/GlossaryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use Symfony\Component\Routing\Attribute\Route;
2727
use Twig\Error\LoaderError;
2828

29-
class GlossaryController extends AbstractFrontController
29+
final class GlossaryController extends AbstractFrontController
3030
{
3131
/**
3232
* @throws Exception
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
}

phpmyfaq/src/phpMyFAQ/Controller/Frontend/OverviewController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use Twig\Error\LoaderError;
3131
use Twig\Extension\AttributeExtension;
3232

33-
class OverviewController extends AbstractFrontController
33+
final class OverviewController extends AbstractFrontController
3434
{
3535
/**
3636
* @throws Exception

phpmyfaq/src/phpMyFAQ/Controller/Frontend/SitemapController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use Symfony\Component\Routing\Attribute\Route;
2929
use Twig\Error\LoaderError;
3030

31-
class SitemapController extends AbstractFrontController
31+
final class SitemapController extends AbstractFrontController
3232
{
3333
/**
3434
* @throws Exception

phpmyfaq/src/public-routes.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use phpMyFAQ\Controller\Frontend\Api\SetupController;
2121
use phpMyFAQ\Controller\Frontend\ContactController;
22-
use phpMyFAQ\Controller\Frontend\GlossaryController;use phpMyFAQ\Controller\Frontend\OverviewController;
22+
use phpMyFAQ\Controller\Frontend\GlossaryController;use phpMyFAQ\Controller\Frontend\LoginController;use phpMyFAQ\Controller\Frontend\OverviewController;
2323
use phpMyFAQ\Controller\Frontend\PageNotFoundController;
2424
use phpMyFAQ\Controller\Frontend\SitemapController as FrontendSitemapController;
2525
use phpMyFAQ\Controller\Frontend\WebAuthnController;
@@ -42,6 +42,11 @@
4242
'controller' => [GlossaryController::class, 'index'],
4343
'methods' => 'GET',
4444
],
45+
'public.login' => [
46+
'path' => '/login',
47+
'controller' => [LoginController::class, 'index'],
48+
'methods' => 'GET|POST',
49+
],
4550
'public.overview' => [
4651
'path' => '/overview.html',
4752
'controller' => [OverviewController::class, 'index'],

0 commit comments

Comments
 (0)