Fix display field in Designer
[phpmyadmin.git] / prefs_twofactor.php
blobabda45ed6eeae3e4a0ac3998bda31c72c09a1722
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * User preferences management page
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Message;
9 use PhpMyAdmin\TwoFactor;
10 use PhpMyAdmin\Template;
12 /**
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_twofactor_confirm')->render([
24 'form' => $two_factor->render(),
25 ]);
26 exit;
27 } else {
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_twofactor_configure')->render([
34 'form' => $two_factor->setup(),
35 'configure' => $_POST['2fa_configure'],
36 ]);
37 exit;
38 } else {
39 Message::rawNotice(__('Two-factor authentication has been configured.'))->display();
43 $backend = $two_factor->backend;
44 echo Template::get('prefs_twofactor')->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(),
51 'missing' => $two_factor->getMissingDeps(),
52 ]);