Skip to content

Commit 028b0d5

Browse files
committed
refactor: migrated user registration page (#3834)
1 parent cb48e5c commit 028b0d5

File tree

3 files changed

+41
-65
lines changed

3 files changed

+41
-65
lines changed

phpmyfaq/register.php

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

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* @package phpMyFAQ
1111
* @author Thorsten Rinne <[email protected]>
1212
* @author Jan Harms <[email protected]>
13-
* @copyright 2012-2026 phpMyFAQ Team
13+
* @copyright 2008-2026 phpMyFAQ Team
1414
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
1515
* @link https://www.phpmyfaq.de
16-
* @since 2012-01-12
16+
* @since 2008-01-25
1717
*/
1818

1919
declare(strict_types=1);
@@ -90,4 +90,38 @@ public function bookmarks(Request $request): Response
9090
'csrfTokenDeleteAllBookmarks' => Token::getInstance($session)->getTokenString('delete-all-bookmarks'),
9191
]);
9292
}
93+
94+
/**
95+
* Displays the user registration page.
96+
*
97+
* @throws Exception
98+
* @throws \Exception
99+
*/
100+
#[Route(path: '/user/register', name: 'public.user.register')]
101+
public function register(Request $request): Response
102+
{
103+
if (!$this->configuration->get('security.enableRegistration')) {
104+
return new RedirectResponse($this->configuration->getDefaultUrl());
105+
}
106+
107+
$faqSession = $this->container->get('phpmyfaq.user.session');
108+
$faqSession->setCurrentUser($this->currentUser);
109+
$faqSession->userTracking('registration', 0);
110+
111+
$captcha = $this->container->get('phpmyfaq.captcha');
112+
$captchaHelper = $this->container->get('phpmyfaq.captcha.helper.captcha_helper');
113+
114+
return $this->render('register.twig', [
115+
...$this->getHeader($request),
116+
'title' => sprintf('%s - %s', Translation::get(key: 'msgRegistration'), $this->configuration->getTitle()),
117+
'lang' => $this->configuration->getLanguage()->getLanguage(),
118+
'isWebAuthnEnabled' => $this->configuration->get('security.enableWebAuthnSupport'),
119+
'captchaFieldset' => $captchaHelper->renderCaptcha(
120+
$captcha,
121+
'register',
122+
Translation::get(key: 'msgCaptcha'),
123+
$this->currentUser->isLoggedIn(),
124+
),
125+
]);
126+
}
93127
}

phpmyfaq/src/public-routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
'controller' => [PrivacyController::class, 'index'],
7979
'methods' => 'GET',
8080
],
81+
'public.user.register' => [
82+
'path' => '/user/register',
83+
'controller' => [UserController::class, 'register'],
84+
'methods' => 'GET',
85+
],
8186
'public.user.request-removal' => [
8287
'path' => '/user/request-removal',
8388
'controller' => [UserController::class, 'requestRemoval'],

0 commit comments

Comments
 (0)