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


PHP PasswordHash::comparePassword方法代码示例

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


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

示例1: login

 public function login($sUsername, $sPassword)
 {
     $oUser = UserQuery::create()->filterByUsername($sUsername)->findOne();
     if ($oUser === null) {
         $oUser = UserQuery::create()->filterByEmail($sUsername)->find();
         if (count($oUser) === 1) {
             $oUser = $oUser[0];
         } else {
             return 0;
         }
     }
     if (!PasswordHash::comparePassword($sPassword, $oUser->getPassword())) {
         if (PasswordHash::comparePasswordFallback($sPassword, $oUser->getPassword())) {
             $oUser->setPassword($sPassword);
             UserPeer::ignoreRights(true);
             $oUser->save();
             return $this->login($sUsername, $sPassword);
         }
         if ($oUser->getPassword() === '*') {
             return self::USER_NEEDS_PASSWORD_RESET;
         }
         return 0;
     }
     if ($oUser->getDigestHA1() === null && Settings::getSetting('security', 'generate_digest_secrets', false) === true) {
         $oUser->setPassword($sPassword);
         UserPeer::ignoreRights(true);
         $oUser->save();
     }
     return $this->loginUser($oUser);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:30,代码来源:Session.php

示例2: validate

 private function validate($aUserData, $oUser)
 {
     $oFlash = Flash::getFlash();
     $oFlash->setArrayToCheck($aUserData);
     $oFlash->checkForValue('username', 'username_required');
     $oFlash->checkForValue('first_name', 'first_name_required');
     $oFlash->checkForValue('last_name', 'last_name_required');
     $oFlash->checkForEmail('email', 'valid_email');
     if ($oUser->isNew() || $aUserData['username'] !== $oUser->getUsername()) {
         $oCheckedUser = UserQuery::create()->filterByUsername($aUserData['username'])->findOne();
         if ($oCheckedUser !== null && $oCheckedUser->getId() !== $oUser->getId()) {
             $oFlash->addMessage('username_exists');
         }
     }
     if ($aUserData['force_password_reset']) {
         // Nothing to validate, pass
     } else {
         if ($aUserData['password'] !== '') {
             if ($oUser->isSessionUser() && $oUser->getPassword() != null) {
                 if ($aUserData['old_password'] == '') {
                     $oFlash->addMessage('old_password_required');
                 } else {
                     if (!PasswordHash::comparePassword($aUserData['old_password'], $oUser->getPassword())) {
                         $oFlash->addMessage('old_password_invalid');
                     }
                 }
             }
             if ($aUserData['password'] !== $aUserData['password_confirm']) {
                 $oFlash->addMessage('password_confirm');
             }
             PasswordHash::checkPasswordValidity($aUserData['password'], $oFlash);
         } else {
             if ($oUser->isNew()) {
                 $oFlash->addMessage('password_new');
             }
         }
     }
     $oFlash->finishReporting();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:39,代码来源:UserDetailWidgetModule.php

示例3: testGeneratedPasswordEncryption

 public function testGeneratedPasswordEncryption()
 {
     $sPassword = PasswordHash::generatePassword();
     $sHash = PasswordHash::hashPassword($sPassword);
     $this->assertSame(true, PasswordHash::comparePassword($sPassword, $sHash));
 }
开发者ID:rapila,项目名称:cms-base,代码行数:6,代码来源:PasswordHashTests.php


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