Use the router for prefs_twofactor.php

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2019-08-20 00:21:19 -03:00
parent bf975c68fd
commit 1de76c66dd
7 changed files with 13 additions and 16 deletions

View File

@ -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 () {

View File

@ -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';

View File

@ -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";

View File

@ -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 */

View File

@ -1,7 +1,7 @@
<div class="group">
<h2>{% trans "Configure two-factor authentication" %}</h2>
<div class="group-cnt">
<form method="POST" action="prefs_twofactor.php">
<form method="post" action="{{ url('/preferences/twofactor') }}">
{{ get_hidden_inputs() }}
<input type="hidden" name="2fa_configure" value="{{ configure }}">
{{ form|raw }}

View File

@ -1,7 +1,7 @@
<div class="group">
<h2>{% trans "Confirm disabling two-factor authentication" %}</h2>
<div class="group-cnt">
<form method="POST" action="prefs_twofactor.php">
<form method="post" action="{{ url('/preferences/twofactor') }}">
{{ "By disabling two factor authentication you will be again able to login using password only."|trans|notice }}
{{ get_hidden_inputs() }}
{{ form|raw }}

View File

@ -32,7 +32,7 @@
<div class="group-cnt">
<p>{% trans "You have enabled two factor authentication." %}</p>
<p>{{ backend_description }}</p>
<form method="post" action="prefs_twofactor.php">
<form method="post" action="{{ url('/preferences/twofactor') }}">
{{ get_hidden_inputs() }}
<input class="btn btn-secondary" type="submit" name="2fa_remove" value="
{%- trans "Disable two-factor authentication" %}">
@ -43,7 +43,7 @@
<div class="group row">
<h2>{% trans "Configure two-factor authentication" %}</h2>
<div class="group-cnt">
<form method="post" action="prefs_twofactor.php">
<form method="post" action="{{ url('/preferences/twofactor') }}">
{{ get_hidden_inputs() }}
{% for backend in backends %}
<label class="displayblock">