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
10 use PhpMyAdmin\Display\ChangePassword
;
11 use PhpMyAdmin\Message
;
12 use PhpMyAdmin\Response
;
13 use PhpMyAdmin\UserPassword
;
16 * Gets some core libraries
18 require_once './libraries/common.inc.php';
20 $response = Response
::getInstance();
21 $header = $response->getHeader();
22 $scripts = $header->getScripts();
23 $scripts->addFile('server_privileges.js');
24 $scripts->addFile('vendor/zxcvbn.js');
26 $userPassword = new UserPassword();
29 * Displays an error message and exits if the user isn't allowed to use this
32 if (! $GLOBALS['cfg']['ShowChgPassword']) {
33 $GLOBALS['cfg']['ShowChgPassword'] = $GLOBALS['dbi']->selectDb('mysql');
35 if ($cfg['Server']['auth_type'] == 'config' ||
! $cfg['ShowChgPassword']) {
37 __('You don\'t have sufficient privileges to be here right now!')
43 * If the "change password" form has been submitted, checks for valid values
44 * and submit the query or logout
46 if (isset($_POST['nopass'])) {
47 if ($_POST['nopass'] == '1') {
50 $password = $_POST['pma_pw'];
52 $change_password_message = $userPassword->setChangePasswordMsg();
53 $msg = $change_password_message['msg'];
54 if (! $change_password_message['error']) {
55 $userPassword->changePassword($password, $msg, $change_password_message);
57 $userPassword->getChangePassMessage($change_password_message);
62 * If the "change password" form hasn't been submitted or the values submitted
63 * aren't valid -> displays the form
66 // Displays an error message if required
72 echo ChangePassword
::getHtml('change_pw', $username, $hostname);