2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * displays and handles the form where the user can change his password
5 * linked from index.php
9 declare(strict_types
=1);
11 use PhpMyAdmin\DatabaseInterface
;
12 use PhpMyAdmin\Display\ChangePassword
;
13 use PhpMyAdmin\Message
;
14 use PhpMyAdmin\Response
;
15 use PhpMyAdmin\UserPassword
;
17 if (! defined('ROOT_PATH')) {
18 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
23 require_once ROOT_PATH
. 'libraries/common.inc.php';
25 /** @var Response $response */
26 $response = $containerBuilder->get(Response
::class);
28 /** @var DatabaseInterface $dbi */
29 $dbi = $containerBuilder->get(DatabaseInterface
::class);
31 $header = $response->getHeader();
32 $scripts = $header->getScripts();
33 $scripts->addFile('server/privileges.js');
34 $scripts->addFile('vendor/zxcvbn.js');
36 /** @var UserPassword $userPassword */
37 $userPassword = $containerBuilder->get('user_password');
40 * Displays an error message and exits if the user isn't allowed to use this
43 if (! $cfg['ShowChgPassword']) {
44 $cfg['ShowChgPassword'] = $dbi->selectDb('mysql');
46 if ($cfg['Server']['auth_type'] == 'config' ||
! $cfg['ShowChgPassword']) {
48 __('You don\'t have sufficient privileges to be here right now!')
54 * If the "change password" form has been submitted, checks for valid values
55 * and submit the query or logout
57 if (isset($_POST['nopass'])) {
58 if ($_POST['nopass'] == '1') {
61 $password = $_POST['pma_pw'];
63 $change_password_message = $userPassword->setChangePasswordMsg();
64 $msg = $change_password_message['msg'];
65 if (! $change_password_message['error']) {
66 $userPassword->changePassword($password, $msg, $change_password_message);
68 $userPassword->getChangePassMessage($change_password_message);
73 * If the "change password" form hasn't been submitted or the values submitted
74 * aren't valid -> displays the form
77 // Displays an error message if required
83 echo ChangePassword
::getHtml('change_pw', $username, $hostname);