2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * User preferences management page
8 use PhpMyAdmin\Message
;
9 use PhpMyAdmin\TwoFactor
;
10 use PhpMyAdmin\Template
;
13 * Gets some core libraries and displays a top message if required
15 require_once 'libraries/common.inc.php';
17 require 'libraries/user_preferences.inc.php';
19 $two_factor = new TwoFactor($GLOBALS['cfg']['Server']['user']);
21 if (isset($_POST['2fa_remove'])) {
22 if (! $two_factor->check(true)) {
23 echo Template
::get('prefs_second_confirm')->render([
24 'form' => $two_factor->render(),
28 $two_factor->configure('');
29 Message
::rawNotice(__('Two-factor authentication has been removed.'))->display();
31 } elseif (isset($_POST['2fa_configure'])) {
32 if (! $two_factor->configure($_POST['2fa_configure'])) {
33 echo Template
::get('prefs_second_configure')->render([
34 'form' => $two_factor->setup(),
35 'configure' => $_POST['2fa_configure'],
39 Message
::rawNotice(__('Two-factor authentication has been configured.'))->display();
43 $backend = $two_factor->backend
;
44 echo Template
::get('prefs_second')->render([
45 'enabled' => $two_factor->writable
,
46 'num_backends' => count($two_factor->available
),
47 'backend_id' => $backend::$id,
48 'backend_name' => $backend::getName(),
49 'backend_description' => $backend::getDescription(),
50 'backends' => $two_factor->getAllBackends(),