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


PHP Authentication::getPasswordHash方法代码示例

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


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

示例1: createOrUpdateUser

 /**
  * @param array $config
  */
 public function createOrUpdateUser($config = array())
 {
     $defaultConfig = array("username" => "admin", "password" => md5(microtime()));
     $settings = array_replace_recursive($defaultConfig, $config);
     if ($user = Model\User::getByName($settings["username"])) {
         $user->delete();
     }
     $user = Model\User::create(array("parentId" => 0, "username" => $settings["username"], "password" => \Pimcore\Tool\Authentication::getPasswordHash($settings["username"], $settings["password"]), "active" => true));
     $user->setAdmin(true);
     $user->save();
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:14,代码来源:Setup.php

示例2: installUser

 private function installUser(\Pimcore\Model\User\Role $userRole)
 {
     $userM = new \Pimcore\Model\User();
     $user = $userM->getByName('kunde');
     if ($user !== FALSE) {
         return $user;
     }
     $user = \Pimcore\Model\User::create(array('parentId' => 0, 'name' => 'kunde', 'password' => \Pimcore\Tool\Authentication::getPasswordHash('kunde', 'kunde'), 'active' => 1, 'language' => 'de', 'admin' => FALSE, 'roles' => array(0 => $userRole->getId())));
     $user->save();
     return $user;
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:11,代码来源:Install.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $user = $input->getOption("user");
     if (!$user) {
         $this->writeError("No username/ID given");
     }
     $method = is_numeric($user) ? 'getById' : 'getByName';
     $user = User::$method($user);
     if (!$user) {
         $this->writeError("User with name " . $user . " could not be found. Exiting");
         exit;
     }
     if ($input->getOption("password")) {
         $plainPassword = $input->getOption("password");
     } else {
         $plainPassword = false;
         while (empty($plainPassword)) {
             $plainPassword = $this->promtSilent();
         }
     }
     $password = \Pimcore\Tool\Authentication::getPasswordHash($user->getName(), $plainPassword);
     $user->setPassword($password);
     $user->save();
     $this->output->writeln("Password for user " . $user->getName() . " reset successfully.");
 }
开发者ID:solverat,项目名称:pimcore,代码行数:25,代码来源:ResetPasswordCommand.php

示例4: updateCurrentUserAction

 public function updateCurrentUserAction()
 {
     $this->protectCSRF();
     $user = $this->getUser();
     if ($user != null) {
         if ($user->getId() == $this->getParam("id")) {
             $values = \Zend_Json::decode($this->getParam("data"));
             unset($values["name"]);
             unset($values["id"]);
             unset($values["admin"]);
             unset($values["permissions"]);
             unset($values["roles"]);
             unset($values["active"]);
             if (!empty($values["new_password"])) {
                 $oldPasswordCheck = false;
                 if (empty($values["old_password"])) {
                     // if the user want to reset the password, the old password isn't required
                     $oldPasswordCheck = Tool\Session::useSession(function ($adminSession) use($oldPasswordCheck) {
                         if ($adminSession->password_reset) {
                             return true;
                         }
                         return false;
                     });
                 } else {
                     // the password has to match
                     $checkUser = Tool\Authentication::authenticatePlaintext($user->getName(), $values["old_password"]);
                     if ($checkUser) {
                         $oldPasswordCheck = true;
                     }
                 }
                 if ($oldPasswordCheck && $values["new_password"] == $values["retype_password"]) {
                     $values["password"] = Tool\Authentication::getPasswordHash($user->getName(), $values["new_password"]);
                 } else {
                     $this->_helper->json(["success" => false, "message" => "password_cannot_be_changed"]);
                 }
             }
             $user->setValues($values);
             $user->save();
             $this->_helper->json(["success" => true]);
         } else {
             \Logger::warn("prevented save current user, because ids do not match. ");
             $this->_helper->json(false);
         }
     } else {
         $this->_helper->json(false);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:47,代码来源:UserController.php

示例5: enableTestMode

 /**
  * Enables the test mode. X-pimcore-unit-test-request=true header will be sent.
  */
 public function enableTestMode()
 {
     $this->client->setHeaders("X-pimcore-unit-test-request", "true");
     if (!$this->getApiKey()) {
         $username = "rest";
         $password = $username;
         $user = User::getByName("{$username}");
         if (!$user) {
             $apikey = md5(time()) . md5($username);
             $user = User::create(array("parentId" => 0, "username" => "rest", "password" => \Pimcore\Tool\Authentication::getPasswordHash($username, $username), "active" => true, "apiKey" => $apikey, "admin" => true));
         }
         $apikey = $user->getApiKey();
         $this->setApiKey($apikey);
     }
     $this->setTestMode(true);
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:19,代码来源:RestClient.php


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