/**
  * @inheritdoc
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     $plain = $credentials[Loader::password()];
     if (Hash::check($plain, $user->getAuthPassword())) {
         return true;
     }
     if ($this->delegator->provider($credentials)->authenticate()) {
         return true;
     }
     return null;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function setCredentials(array $credentials)
 {
     if ($credentials) {
         $this->credentials = $credentials;
         $this->username = $this->credentials[Loader::username()];
         if (strstr($this->username, "@")) {
             list($this->login, $this->domain) = explode("@", $this->username);
         }
         $this->password = $this->credentials[Loader::password()];
     }
     return $this;
 }
 /**
  * @inheritdoc
  */
 public function authenticate()
 {
     $users = Loader::domain($this->domain)['users'];
     if (!isset($users[$this->username])) {
         return null;
     }
     $password = $users[$this->username];
     if (Hash::check($this->password, $password)) {
         $newUser = $this->model();
         $newUser->{Loader::username()} = $this->username;
         $newUser->{Loader::password()} = $password;
         $newUser->enabled = true;
         $newUser->save();
         return $newUser;
     }
     return null;
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function register($user)
 {
     $mapping = new LdapMapping($this->config['mappings']);
     $user[Loader::password()][0] = Hash::make($this->password);
     return $mapping->map($user, $this->model());
 }
 /**
  * Check credentials fields from auth config
  *
  * @param $credentials
  *
  * @throws \Exception
  */
 private function checkFields($credentials)
 {
     if (!isset($credentials[Loader::username()])) {
         throw new \Exception("Unsupported credentials array. Must define '" . Loader::username() . "' key for username", 1);
     }
     if (!isset($credentials[Loader::password()])) {
         throw new \Exception("Unsupported credentials array. Must define '" . Loader::password() . "' key for password", 1);
     }
 }