addScriptFiles(['server/privileges.js', 'vendor/zxcvbn-ts.js']); /** * Displays an error message and exits if the user isn't allowed to use this * script */ if (! $GLOBALS['cfg']['ShowChgPassword']) { $GLOBALS['cfg']['ShowChgPassword'] = $this->dbi->selectDb('mysql'); } if ($GLOBALS['cfg']['Server']['auth_type'] === 'config' || ! $GLOBALS['cfg']['ShowChgPassword']) { $this->response->addHTML(Message::error( __('You don\'t have sufficient privileges to be here right now!'), )->getDisplay()); return; } $noPass = $request->getParsedBodyParam('nopass'); $pmaPw = $request->getParsedBodyParam('pma_pw'); $pmaPw2 = $request->getParsedBodyParam('pma_pw2'); /** * If the "change password" form has been submitted, checks for valid values * and submit the query or logout */ if ($noPass !== null) { if ($noPass == '1') { $password = ''; } else { $password = $pmaPw; } $GLOBALS['change_password_message'] = $this->userPassword->setChangePasswordMsg( $pmaPw, $pmaPw2, (bool) $noPass, ); $GLOBALS['msg'] = $GLOBALS['change_password_message']['msg']; if (! $GLOBALS['change_password_message']['error']) { $sql_query = $this->userPassword->changePassword( $password, $request->getParsedBodyParam('authentication_plugin'), ); if ($this->response->isAjax()) { $sql_query = Generator::getMessage( $GLOBALS['change_password_message']['msg'], $sql_query, 'success', ); $this->response->addJSON('message', $sql_query); return; } $this->response->addHTML('

' . __('Change password') . '

' . "\n\n"); $this->response->addHTML(Generator::getMessage($GLOBALS['msg'], $sql_query, 'success')); $this->render('user_password'); return; } if ($this->response->isAjax()) { $this->response->addJSON('message', $GLOBALS['change_password_message']['msg']); $this->response->setRequestStatus(false); return; } } /** * If the "change password" form hasn't been submitted or the values submitted * aren't valid -> displays the form */ // Displays an error message if required if (isset($GLOBALS['msg'])) { $this->response->addHTML($GLOBALS['msg']->getDisplay()); } $this->response->addHTML($this->userPassword->getFormForChangePassword( $GLOBALS['username'], $GLOBALS['hostname'], $request->getRoute(), )); } }