예제 #1
0
 /**
  * @param User $user
  * @param $password
  * @return bool
  */
 public static function verifyPassword($user, $password)
 {
     $password = self::preparePlainTextPassword($user->getName(), $password);
     if ($user->getPassword()) {
         // do not allow logins for users without a password
         if (password_verify($password, $user->getPassword())) {
             if (password_needs_rehash($user->getPassword(), PASSWORD_DEFAULT)) {
                 $user->setPassword(self::getPasswordHash($user->getName(), $password));
                 $user->save();
             }
             return true;
         }
     }
     return false;
 }
예제 #2
0
파일: Admin.php 프로젝트: solverat/pimcore
 /**
  * @param Model\User $user
  * @return $this
  */
 public function setUser(Model\User $user)
 {
     $this->user = $user;
     \Zend_Registry::set("pimcore_admin_user", $this->user);
     $this->setLanguage($this->user->getLanguage());
     // update perspective settings
     $requestedPerspective = $this->getParam("perspective");
     if ($requestedPerspective) {
         if ($requestedPerspective != $user->getActivePerspective()) {
             $existingPerspectives = array_keys(Config::getPerspectivesConfig()->toArray());
             if (!in_array($requestedPerspective, $existingPerspectives)) {
                 $requestedPerspective = null;
             }
         }
     }
     if (!$requestedPerspective) {
         $requestedPerspective = $user->getActivePerspective();
     }
     //TODO check if perspective is still allowed
     if ($requestedPerspective != $user->getActivePerspective()) {
         $user->setActivePerspective($requestedPerspective);
         $user->save();
     }
     return $this;
 }
예제 #3
0
파일: Admin.php 프로젝트: pimcore/pimcore
 /**
  * @param Model\User $user
  * @return $this
  */
 public function setUser(Model\User $user)
 {
     $this->user = $user;
     \Zend_Registry::set("pimcore_admin_user", $this->user);
     $this->setLanguage($this->user->getLanguage());
     // update perspective settings
     $requestedPerspective = $this->getParam("perspective");
     if ($requestedPerspective) {
         if ($requestedPerspective != $user->getActivePerspective()) {
             $existingPerspectives = array_keys(Config::getPerspectivesConfig()->toArray());
             if (!in_array($requestedPerspective, $existingPerspectives)) {
                 $requestedPerspective = null;
             }
         }
     }
     if (!$requestedPerspective || !$user->isAllowed($requestedPerspective, "perspective")) {
         //choose active perspective or a first allowed
         $requestedPerspective = $user->isAllowed($user->getActivePerspective(), "perspective") ? $user->getActivePerspective() : $user->getFirstAllowedPerspective();
     }
     if ($requestedPerspective != $user->getActivePerspective()) {
         $user->setActivePerspective($requestedPerspective);
         $user->save();
     }
     return $this;
 }