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


PHP User::hashPassword方法代码示例

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


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

示例1: addIdentity

 public function addIdentity($identity, $user_id)
 {
     $user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($user_id);
     $crit = $this->getCriteria();
     $crit->addInsert(self::IDENTITY, $identity);
     $crit->addInsert(self::IDENTITY_HASH, User::hashPassword($identity, $user->getSalt()));
     $crit->addInsert(self::UID, $user_id);
     $type = 'openid';
     foreach (self::getProviders() as $provider => $string) {
         if (stripos($identity, $string) !== false) {
             $type = $provider;
             break;
         }
     }
     $crit->addInsert(self::TYPE, $type);
     $this->doInsert($crit);
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:17,代码来源:OpenIdAccounts.php

示例2: runAuthenticate

 public function runAuthenticate(framework\Request $request)
 {
     $username = trim($request['username']);
     $password = trim($request['password']);
     if ($username) {
         $user = tables\Users::getTable()->getByUsername($username);
         if ($password && $user instanceof entities\User) {
             foreach ($user->getApplicationPasswords() as $app_password) {
                 if (!$app_password->isUsed()) {
                     if ($app_password->getHashPassword() == entities\User::hashPassword($password, $user->getSalt())) {
                         $app_password->useOnce();
                         $app_password->save();
                         return $this->renderJSON(array('token' => $app_password->getHashPassword()));
                     }
                 }
             }
         }
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => 'Incorrect username or application password'));
 }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:21,代码来源:Main.php

示例3: doLogin


//.........这里部分代码省略.........
             }
             if ($allowed == false) {
                 throw new \Exception(framework\Context::getI18n()->__('You are not a member of a group allowed to log in'));
             }
         }
         /*
          * Set user's properties.
          * Realname is obtained from directory, if not found we set it to the username
          * Email is obtained from directory, if not found we set it to blank
          */
         if (!array_key_exists(strtolower($fullname_attr), $data[0])) {
             $realname = $username;
         } else {
             $realname = $data[0][strtolower($fullname_attr)][0];
         }
         if (!array_key_exists(strtolower($buddyname_attr), $data[0])) {
             $buddyname = $username;
         } else {
             $buddyname = $data[0][strtolower($buddyname_attr)][0];
         }
         if (!array_key_exists(strtolower($email_attr), $data[0])) {
             $email = '';
         } else {
             $email = $data[0][strtolower($email_attr)][0];
         }
         /*
          * If we are performing a non integrated authentication login,
          * now bind to the user and see if the credentials
          * are valid. We bind using the full DN of the user, so no need for DOMAIN\ stuff
          * on Windows, and more importantly it fixes other servers.
          *
          * If the bind fails (exception), we throw a nicer exception and don't continue.
          */
         if ($mode == 1 && !$integrated_auth) {
             try {
                 if (!is_array($data[0][strtolower($dn_attr)])) {
                     $dn = $data[0][strtolower($dn_attr)];
                 } else {
                     $dn = $data[0][strtolower($dn_attr)][0];
                 }
                 $bind = $this->bind($connection, $this->escape($dn), $password);
             } catch (\Exception $e) {
                 throw new \Exception(framework\Context::geti18n()->__('Your password was not accepted by the server'));
             }
         } elseif ($mode == 1) {
             if (!isset($_SERVER[$this->getSetting('integrated_auth_header')]) || $_SERVER[$this->getSetting('integrated_auth_header')] != $username) {
                 throw new \Exception(framework\Context::geti18n()->__('HTTP authentication internal error.'));
             }
         }
     } catch (\Exception $e) {
         ldap_unbind($connection);
         throw $e;
     }
     try {
         /*
          * Get the user object. If the user exists, update the user's
          * data from the directory.
          */
         $user = \thebuggenie\core\entities\User::getByUsername($username);
         if ($user instanceof \thebuggenie\core\entities\User) {
             $user->setBuddyname($buddyname);
             $user->setRealname($realname);
             $user->setPassword($user->getJoinedDate() . $username);
             // update password
             $user->setEmail($email);
             // update email address
             $user->save();
         } else {
             /*
              * If not, and we are performing an initial login, create the user object
              * if we are validating a log in, kick the user out as the session is invalid.
              */
             if ($mode == 1) {
                 // create user
                 $user = new \thebuggenie\core\entities\User();
                 $user->setUsername($username);
                 $user->setRealname('temporary');
                 $user->setBuddyname($username);
                 $user->setEmail('temporary');
                 $user->setEnabled();
                 $user->setActivated();
                 $user->setJoined();
                 $user->setPassword($user->getJoinedDate() . $username);
                 $user->save();
             } else {
                 throw new \Exception('User does not exist in TBG');
             }
         }
     } catch (\Exception $e) {
         ldap_unbind($connection);
         throw $e;
     }
     ldap_unbind($connection);
     /*
      * Set cookies and return user row for general operations.
      */
     framework\Context::getResponse()->setCookie('tbg3_username', $username);
     framework\Context::getResponse()->setCookie('tbg3_password', \thebuggenie\core\entities\User::hashPassword($user->getJoinedDate() . $username, $user->getSalt()));
     return \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($username);
 }
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:101,代码来源:Auth_ldap.php

示例4: setPassword

 /**
  * Set a new application password. Generates token & crypts the token.
  *
  * @param string $newpassword
  */
 public function setPassword($newpassword)
 {
     $token = self::createToken($newpassword);
     $this->_password = \thebuggenie\core\entities\User::hashPassword($token, $this->getUser()->getSalt());
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:10,代码来源:ApplicationPassword.php

示例5: runAuthenticate

 /**
  * Authenticate an application using a one-time application password.
  * Creates a token to be used for subsequent requests.
  * 
  * @param framework\Request $request
  */
 public function runAuthenticate(framework\Request $request)
 {
     framework\Logging::log('Authenticating new application password.', 'api', framework\Logging::LEVEL_INFO);
     $username = trim($request['username']);
     $password = trim($request['password']);
     if ($username) {
         $user = tables\Users::getTable()->getByUsername($username);
         if ($password && $user instanceof entities\User) {
             // Generate token from the application password
             $token = entities\ApplicationPassword::createToken($password);
             // Crypt, for comparison with db value
             $hashed_token = entities\User::hashPassword($token, $user->getSalt());
             foreach ($user->getApplicationPasswords() as $app_password) {
                 // Only return the token for new application passwords!
                 if (!$app_password->isUsed()) {
                     if ($app_password->getHashPassword() == $hashed_token) {
                         $app_password->useOnce();
                         $app_password->save();
                         return $this->renderJSON(array('token' => $token, 'name' => $app_password->getName(), 'created_at' => $app_password->getCreatedAt()));
                     }
                 }
             }
         }
         framework\Logging::log('No password matched.', 'api', framework\Logging::LEVEL_INFO);
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('error' => 'Incorrect username or application password'));
 }
开发者ID:thebuggenie,项目名称:module-api,代码行数:34,代码来源:Main.php

示例6: setPassword

 /**
  * Set password
  *
  * @param string $newpassword
  *
  * @see \thebuggenie\core\entities\User::changePassword
  */
 public function setPassword($newpassword)
 {
     $this->_password = \thebuggenie\core\entities\User::hashPassword($newpassword, $this->getUser()->getSalt());
 }
开发者ID:founderio,项目名称:thebuggenie,代码行数:11,代码来源:ApplicationPassword.php


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