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


PHP User::getByName方法代码示例

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


在下文中一共展示了User::getByName方法的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: lostpasswordAction

 public function lostpasswordAction()
 {
     $username = $this->getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Tool\Authentication::generateToken($username, $user->getPassword());
                     $uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
                     $loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token . "&reset=true";
                     try {
                         $mail = Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setIgnoreDebugMode(true);
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (\Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:31,代码来源:LoginController.php

示例3: init

 public function init()
 {
     $this->allParam = $this->getAllParams();
     // set api key
     $this->apiKey = isset($this->apiKey) ? $this->apiKey : \Pimcore\Model\User::getByName($this->userApiBridgeMagento)->getApiKey();
     if (!$this->validateApiKey()) {
         die;
         // no any error info provided
     }
     // init api
     $this->apiModel = new ApiBridgeMagento_Api();
 }
开发者ID:oleksandrmakhno,项目名称:api-bridge-magento,代码行数:12,代码来源:ApiController.php

示例4: authenticateToken

 /**
  * @param $username
  * @param $token
  * @param bool $adminRequired
  * @return null|User
  */
 public static function authenticateToken($username, $token, $adminRequired = false)
 {
     $user = User::getByName($username);
     if (self::isValidUser($user)) {
         if ($adminRequired and !$user->isAdmin()) {
             return null;
         }
         $passwordHash = $user->getPassword();
         $decrypted = self::tokenDecrypt($passwordHash, $token);
         $timestamp = $decrypted[0];
         $timeZone = date_default_timezone_get();
         date_default_timezone_set("UTC");
         if ($timestamp > time() or $timestamp < time() - 60 * 30) {
             return null;
         }
         date_default_timezone_set($timeZone);
         return $user;
     }
     return null;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:26,代码来源:Authentication.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\Model\User::getByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。