當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。