Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function authenticate($data, UserModel $userModel, PasswordHasher $hasher)
 {
     $this->cookie = isset($data['remember']);
     $idData = array();
     $idData[$this->options['username']] = $data[$this->options['username']];
     $user = $userModel->findUser($idData);
     if (isset($user)) {
         $password = $userModel->getPassword($user);
         if ($hasher->compare($data['password'], $password)) {
             return $user;
         }
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function authenticate($data, UserModel $userModel, PasswordHasher $hasher)
 {
     if (!isset($this->options['realm'])) {
         $this->options['realm'] = $_SERVER['SERVER_NAME'];
     }
     if (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) {
         $idData = array();
         $idData[$this->options['usernameField']] = $_SERVER['PHP_AUTH_USER'];
         $user = $userModel->findUser($idData);
         if (isset($user)) {
             $password = $userModel->getPassword($user);
             if ($hasher->compare($_SERVER['PHP_AUTH_PW'], $password)) {
                 return $user;
             }
         }
     }
     return null;
 }