Exemplo n.º 1
2
 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;
 }
Exemplo n.º 2
1
 /**
  * @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();
 }
Exemplo n.º 3
0
 /**
  * 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 = "******";
         $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);
 }