当前位置: 首页>>代码示例>>PHP>>正文


PHP UserDB::updatePassword方法代码示例

本文整理汇总了PHP中UserDB::updatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDB::updatePassword方法的具体用法?PHP UserDB::updatePassword怎么用?PHP UserDB::updatePassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserDB的用法示例。


在下文中一共展示了UserDB::updatePassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 public static function post()
 {
     if (isset($_POST['save'])) {
         $page = new Page();
         $page->data['title'] = 'Wachtwoord wijzigen';
         $errMsgs = ChangePasswordViewValidator::validate($_POST);
         if (empty($errMsgs)) {
             try {
                 $passwordSalt = UserDB::getPasswordSaltByUserId($_SESSION['Stippers']['user']->userId);
                 $oldPasswordHash = hash_pbkdf2('sha256', $_POST['old_password'], $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
                 //If the old password is incorrect, show an error
                 if ($_SESSION['Stippers']['ChangePassword']['user']->passwordHash != $oldPasswordHash) {
                     ChangePasswordController::buildChangePasswordView($page);
                     $page->data['ChangePasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="change_password_form_error_message">Het oude wachtwoord is fout.</h2>';
                 } else {
                     $newPasswordHash = hash_pbkdf2('sha256', $_POST['new_password'], $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
                     UserDB::updatePassword($_SESSION['Stippers']['ChangePassword']['user'], $newPasswordHash);
                     $_SESSION['Stippers']['user']->passwordHash = $newPasswordHash;
                     //Show success view
                     $page->data['SuccessMessageNoDescriptionWithLinkView']['successTitle'] = 'Wachtwoord succesvol gewijzigd';
                     $page->data['SuccessMessageNoDescriptionWithLinkView']['redirectUrl'] = 'profile';
                     $page->addView('success/SuccessMessageNoDescriptionWithLinkView');
                 }
             } catch (UserDBException $ex) {
                 //Show correct error message for errors
                 if ($ex->getCode() == UserDBException::USEROUTOFDATE) {
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Wachtwoord niet gewijzigd';
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft je gegevens in tussentijd al gewijzigd.';
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
                     $page->addView('error/ErrorMessageWithDescriptionWithLinkView');
                 } else {
                     ChangePasswordController::buildChangePasswordView($page);
                     $page->data['ChangePasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="change_password_form_error_message">Kan wachtwoord niet wijzigen, probeer het opnieuw.</h2>';
                 }
             } catch (Exception $ex) {
                 ChangePasswordController::buildChangePasswordView($page);
                 $page->data['ChangePasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="change_password_form_error_message">Kan wachtwoord niet wijzigen, probeer het opnieuw.</h2>';
             }
         } else {
             //If we had an error we show the page again with errors
             ChangePasswordController::buildChangePasswordView($page);
             $page->data['ChangePasswordView']['errMsgs'] = array_merge($page->data['ChangePasswordView']['errMsgs'], $errMsgs);
         }
         $page->showWithMenu();
     } else {
         ChangePasswordController::get();
     }
 }
开发者ID:JHDeStip,项目名称:Stippers,代码行数:48,代码来源:ChangePasswordController.php


注:本文中的UserDB::updatePassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。