diff --git a/index.php b/index.php index 109ed21338..efee6c0972 100644 --- a/index.php +++ b/index.php @@ -129,6 +129,9 @@ if (isset($_GET['route']) || isset($_POST['route'])) { $routes->addRoute(['GET', 'POST'], '/manage', function () { require_once ROOT_PATH . 'libraries/entry_points/preferences/manage.php'; }); + $routes->addRoute(['GET', 'POST'], '/twofactor', function () { + require_once ROOT_PATH . 'libraries/entry_points/preferences/twofactor.php'; + }); }); $routes->addGroup('/server', function (RouteCollector $routes) { $routes->addRoute(['GET', 'POST'], '/binlog', function () { diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index 65854e55c8..b8affe35a1 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -631,12 +631,11 @@ class Menu $tabs['settings']['icon'] = 'b_tblops'; $tabs['settings']['link'] = Url::getFromRoute('/preferences/manage'); $tabs['settings']['text'] = __('Settings'); - $tabs['settings']['active'] = in_array(basename($GLOBALS['PMA_PHP_SELF']), [ - 'prefs_twofactor.php', - ]) || (isset($_REQUEST['route']) && in_array($_REQUEST['route'], [ + $tabs['settings']['active'] = isset($_REQUEST['route']) && in_array($_REQUEST['route'], [ '/preferences/forms', '/preferences/manage', - ])); + '/preferences/twofactor', + ]); if (! empty($binary_logs)) { $tabs['binlog']['icon'] = 's_tbl'; diff --git a/libraries/classes/UserPreferencesHeader.php b/libraries/classes/UserPreferencesHeader.php index 8beb2deddb..957b31891e 100644 --- a/libraries/classes/UserPreferencesHeader.php +++ b/libraries/classes/UserPreferencesHeader.php @@ -62,7 +62,7 @@ class UserPreferencesHeader /* Second authentication factor */ $content .= Util::getHtmlTab( [ - 'link' => 'prefs_twofactor.php', + 'link' => 'index.php?route=/preferences/twofactor', 'text' => __('Two-factor authentication'), ] ) . "\n"; diff --git a/prefs_twofactor.php b/libraries/entry_points/preferences/twofactor.php similarity index 89% rename from prefs_twofactor.php rename to libraries/entry_points/preferences/twofactor.php index 7832b0d650..98e4946fe6 100644 --- a/prefs_twofactor.php +++ b/libraries/entry_points/preferences/twofactor.php @@ -13,17 +13,12 @@ use PhpMyAdmin\Template; use PhpMyAdmin\TwoFactor; use PhpMyAdmin\UserPreferencesHeader; -if (! defined('ROOT_PATH')) { - define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); +if (! defined('PHPMYADMIN')) { + exit; } global $containerBuilder; -/** - * Gets some core libraries and displays a top message if required - */ -require_once ROOT_PATH . 'libraries/common.inc.php'; - /** @var Template $template */ $template = $containerBuilder->get('template'); /** @var Relation $relation */ diff --git a/templates/preferences/two_factor/configure.twig b/templates/preferences/two_factor/configure.twig index 574f112a85..6bf74a309b 100644 --- a/templates/preferences/two_factor/configure.twig +++ b/templates/preferences/two_factor/configure.twig @@ -1,7 +1,7 @@