當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper::bCryptVerifyPassword方法代碼示例

本文整理匯總了PHP中Library\Utility\Helper::bCryptVerifyPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::bCryptVerifyPassword方法的具體用法?PHP Helper::bCryptVerifyPassword怎麽用?PHP Helper::bCryptVerifyPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Library\Utility\Helper的用法示例。


在下文中一共展示了Helper::bCryptVerifyPassword方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ajaxChangePasswordAction

 public function ajaxChangePasswordAction()
 {
     /**
      * @var UserManager $rUserDao
      * @var \DDD\Domain\User\User $rUser
      */
     $request = $this->getRequest();
     $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
     try {
         if ($request->isXmlHttpRequest()) {
             $form = new ProfilePasswordForm('changePassword');
             $messages = '';
             $data = $request->getPost();
             $form->setInputFilter(new ProfilePasswordFilter());
             if ($request->isPost()) {
                 /**
                  * @var \DDD\Service\User $userService
                  */
                 $userService = $this->getServiceLocator()->get('service_user');
                 $filter = $form->getInputFilter();
                 $form->setInputFilter($filter);
                 $rUserDao = $this->getServiceLocator()->get('dao_user_user_manager');
                 $rUser = $rUserDao->findUserById((int) $data['userId']);
                 if (!Helper::bCryptVerifyPassword($data['currentPassword'], $rUser->getPassword())) {
                     return new JsonModel(['status' => 'error', 'msg' => 'Current password is wrong.']);
                 }
                 $form->setData($data);
                 if ($form->isValid()) {
                     $userService->changePassword($data);
                     Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
                 } else {
                     $errors = $form->getMessages();
                     foreach ($errors as $key => $row) {
                         if (!empty($row)) {
                             $messages .= ucfirst($key) . ' ';
                             $messages_sub = '';
                             foreach ($row as $keyer => $rower) {
                                 $messages_sub .= $rower;
                             }
                             $messages .= $messages_sub . '<br>';
                         }
                     }
                     $result['status'] = 'error';
                     $result['msg'] = $messages;
                 }
             }
         }
     } catch (\Exception $e) {
         echo $e->getMessage();
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:54,代碼來源:ProfileController.php


注:本文中的Library\Utility\Helper::bCryptVerifyPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。