2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * User preferences management page
8 declare(strict_types
=1);
10 use PhpMyAdmin\Message
;
11 use PhpMyAdmin\Relation
;
12 use PhpMyAdmin\Template
;
13 use PhpMyAdmin\TwoFactor
;
14 use PhpMyAdmin\UserPreferencesHeader
;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
21 * Gets some core libraries and displays a top message if required
23 require_once ROOT_PATH
. 'libraries/common.inc.php';
25 /** @var Template $template */
26 $template = $containerBuilder->get('template');
27 /** @var Relation $relation */
28 $relation = $containerBuilder->get('relation');
29 echo UserPreferencesHeader
::getContent($template, $relation);
31 $two_factor = new TwoFactor($GLOBALS['cfg']['Server']['user']);
33 if (isset($_POST['2fa_remove'])) {
34 if (! $two_factor->check(true)) {
35 echo $template->render('preferences/two_factor/confirm', [
36 'form' => $two_factor->render(),
40 $two_factor->configure('');
41 Message
::rawNotice(__('Two-factor authentication has been removed.'))->display();
43 } elseif (isset($_POST['2fa_configure'])) {
44 if (! $two_factor->configure($_POST['2fa_configure'])) {
45 echo $template->render('preferences/two_factor/configure', [
46 'form' => $two_factor->setup(),
47 'configure' => $_POST['2fa_configure'],
51 Message
::rawNotice(__('Two-factor authentication has been configured.'))->display();
55 $backend = $two_factor->backend
;
56 echo $template->render('preferences/two_factor/main', [
57 'enabled' => $two_factor->writable
,
58 'num_backends' => count($two_factor->available
),
59 'backend_id' => $backend::$id,
60 'backend_name' => $backend::getName(),
61 'backend_description' => $backend::getDescription(),
62 'backends' => $two_factor->getAllBackends(),
63 'missing' => $two_factor->getMissingDeps(),