-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrated admin session keepalive to controller (#3257)
- Loading branch information
Showing
8 changed files
with
70 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
phpmyfaq/src/phpMyFAQ/Controller/Administration/SessionKeepAliveController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/** | ||
* The Session Keepalive Controller | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* @package phpMyFAQ | ||
* @author Thorsten Rinne <thorsten@phpmyfaq.de> | ||
* @copyright 2024 phpMyFAQ Team | ||
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 | ||
* @link https://www.phpmyfaq.de | ||
* @since 2024-11-23 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpMyFAQ\Controller\Administration; | ||
|
||
use phpMyFAQ\Core\Exception; | ||
use phpMyFAQ\Filter; | ||
use phpMyFAQ\Session\Token; | ||
use phpMyFAQ\System; | ||
use phpMyFAQ\Translation; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Twig\Error\LoaderError; | ||
|
||
class SessionKeepAliveController extends AbstractAdministrationController | ||
{ | ||
/** | ||
* @throws Exception | ||
* @throws LoaderError | ||
* @throws \Exception | ||
*/ | ||
#[Route('/session-keep-alive', name: 'admin.session.keepalive', methods: ['GET'])] | ||
public function index(Request $request): Response | ||
{ | ||
$language = Filter::filterVar($request->query->get('lang', 'en'), FILTER_SANITIZE_SPECIAL_CHARS); | ||
$refreshTime = (PMF_AUTH_TIMEOUT - PMF_AUTH_TIMEOUT_WARNING) * 60; | ||
|
||
return $this->render( | ||
'@admin/session-keepalive.twig', | ||
[ | ||
'metaLanguage' => $language, | ||
'phpMyFAQVersion' => System::getVersion(), | ||
'currentYear' => date('Y'), | ||
'isUserLoggedIn' => $this->currentUser->isLoggedIn(), | ||
'csrfToken' => Token::getInstance($this->container->get('session'))->getTokenString('admin-logout'), | ||
'msgConfirm' => sprintf(Translation::get('ad_session_expiring'), PMF_AUTH_TIMEOUT_WARNING), | ||
'sessionTimeout' => PMF_AUTH_TIMEOUT, | ||
'refreshTime' => $refreshTime, | ||
] | ||
); | ||
} | ||
} |