/**
  * {@inheritdoc}
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     if (parent::validateCredentials($user, $credentials)) {
         return true;
     }
     throw new AuthenticationException("Incorrect password");
 }
 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array  $credentials
  * @return \Illuminate\Auth\UserInterface|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     Kinvey::setAuthMode('admin');
     $result = parent::retrieveByCredentials($credentials);
     Kinvey::setAuthMode('app');
     return $result;
 }
Beispiel #3
0
 public function retrieveByCredentials(array $credentials)
 {
     // Get the username input attributes
     $attributes = $this->getUsernameAttribute();
     // Get the input key
     $key = key($attributes);
     $ldapUser = Ldap::find('people')->where($attributes[$key], $credentials[$key])->get();
     // Retrieve the users login attribute.
     $username = $ldapUser[$attributes[$key]];
     if (is_array($username)) {
         // We'll make sure we retrieve the users first username
         // attribute if it's contained in an array.
         $username = Arr::get($username, 0);
     }
     // Get the password input array key.
     $key = $this->getPasswordKey();
     // Try to log the user in.
     if (Ldap::auth($username, $credentials[$key])) {
         // Login was successful, we'll create a new
         // Laravel model with the Adldap user.
         return $this->getModelFromLdap($ldapUser, $credentials[$key]);
     }
     if ($this->getLoginFallback()) {
         // Login failed. If login fallback is enabled
         // we'll call the eloquent driver.
         return parent::retrieveByCredentials($credentials);
     }
     return;
 }
 /**
  * [validateCredentials description].
  *
  * @param Authenticatable $user        [description]
  * @param array           $credentials [description]
  *
  * @return [type] [description]
  */
 public function validateCredentials(Authenticatable $user, array $credentials)
 {
     if (isset($credentials['password'])) {
         return parent::validateCredentials($user, $credentials);
     }
     // We only get a user if retrieveByCredentials found one, no validation needed.
     return !empty($user);
 }
 /**
  * {@inheritdoc}
  */
 public function retrieveByCredentials(array $credentials)
 {
     // Get the search query for users only.
     $query = $this->newAdldapUserQuery();
     // Make sure the connection is bound
     // before we try to utilize it.
     if ($query->getConnection()->isBound()) {
         // Get the username input attributes.
         $attributes = $this->getUsernameAttribute();
         // Get the input key.
         $key = key($attributes);
         // Filter the query by the username attribute.
         $query->whereEquals($attributes[$key], $credentials[$key]);
         // Retrieve the first user result.
         $user = $query->first();
         // Edited by Minkbear: In case of not found.
         if (!$user) {
             return null;
         }
         // Edited by Minkbear: Convert \Adldap\Models\Entry to \Adldap\Models\User
         if ($user instanceof \Adldap\Models\Entry) {
             $u = new User($user->getAttributes(), $query);
         }
         // If the user is an Adldap User model instance.
         if ($user instanceof User) {
             // Retrieve the users login attribute.
             $username = $u->{$this->getLoginAttribute()};
             if (is_array($username)) {
                 // We'll make sure we retrieve the users first username
                 // attribute if it's contained in an array.
                 $username = Arr::get($username, 0);
             }
             // Retrieve the password from the submitted credentials.
             $password = Arr::get($credentials, $this->getPasswordKey());
             // Edited by Minkbear: Change user into pattern you give
             // Obsolate this function
             //$username = $this->getUsernameLoginPattern($username);
             // Try to log the user in.
             if (!is_null($password) && $this->authenticate($user->{'dn'}, $password)) {
                 // Login was successful, we'll create a new
                 // Laravel model with the Adldap user.
                 return $this->getModelFromAdldap($u, $password);
             }
         }
     }
     if ($this->getLoginFallback()) {
         // Login failed. If login fallback is enabled
         // we'll call the eloquent driver.
         return parent::retrieveByCredentials($credentials);
     }
 }
 /**
  * Replicates the original method behaviour, but also adds the ability to find a user by its Social Network Link.
  * @param array $credentials
  * @return \Illuminate\Database\Eloquent\Model|null|static
  */
 public function retrieveByCredentials(array $credentials)
 {
     if (isset($credentials['provider'])) {
         $network = SocialNetwork::find($credentials['provider']);
         if ($network) {
             /** @var SocialLink $profile */
             $profile = $network->links()->where('username', $credentials['username'])->get();
             if ($profile) {
                 return $profile->user;
             }
         }
         return null;
     } else {
         return parent::retrieveByCredentials($credentials);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function retrieveByCredentials(array $credentials)
 {
     // Get the search query for users only
     $query = $this->newAdldapUserQuery();
     // Get the username input attributes
     $attributes = $this->getUsernameAttribute();
     // Get the input key
     $key = key($attributes);
     // Filter the query by the username attribute
     $query->whereEquals($attributes[$key], $credentials[$key]);
     // Retrieve the first user result
     $user = $query->first();
     // If the user is an Adldap User model instance.
     if ($user instanceof User) {
         // Retrieve the users login attribute.
         $username = $user->{$this->getLoginAttribute()};
         if (is_array($username)) {
             // We'll make sure we retrieve the users first username
             // attribute if it's contained in an array.
             $username = Arr::get($username, 0);
         }
         // Get the password input array key.
         $key = $this->getPasswordKey();
         // Try to log the user in.
         if ($this->authenticate($username, $credentials[$key])) {
             // Login was successful, we'll create a new
             // Laravel model with the Adldap user.
             return $this->getModelFromAdldap($user, $credentials[$key]);
         }
     }
     if ($this->getLoginFallback()) {
         // Login failed. If login fallback is enabled
         // we'll call the eloquent driver.
         return parent::retrieveByCredentials($credentials);
     }
     return;
 }
 /**
  * Create a new database user provider.
  *
  * @param  \Illuminate\Contracts\Hashing\Hasher $hasher
  * @param  string $model
  */
 public function __construct(Hasher $hasher, $model)
 {
     parent::__construct($hasher, $model);
 }
 /**
  * {@inheritdoc}
  */
 public function validateCredentials(Authenticatable $user, array $credentials)
 {
     // Check if we have an authenticated AD user.
     if ($this->user instanceof User) {
         // We'll save the authenticated model in case of changes.
         $user->save();
         return true;
     }
     if ($this->getLoginFallback() && $user->exists) {
         // If the user exists in our local database already and fallback is
         // enabled, we'll perform standard eloquent authentication.
         return parent::validateCredentials($user, $credentials);
     }
     return false;
 }
 public function __construct(HasherContract $hasher, $model, $adldap)
 {
     $this->adldap = $adldap;
     parent::__construct($hasher, $model);
 }
 public function __construct(HasherInterface $hasher, $model, $config)
 {
     parent::__construct($hasher, $model);
     $this->config = $config;
 }
 /**
  * @param HasherContract $hasher
  * @param string $model
  * @param CacheContract $cache
  */
 public function __construct(HasherContract $hasher, $model, CacheContract $cache)
 {
     parent::__construct($hasher, $model);
     $this->cache = $cache;
 }
 public function updateRememberToken(UserContract $user, $token)
 {
     $current_user = parent::retrieveById($user->id);
     $current_user->setRememberToken($token);
     $current_user->save();
 }
 public function __construct(HasherInterface $hasher, $model, $config)
 {
     parent::__construct($hasher, $model);
     $this->config = $config;
     $this->adLdap = new adLDAP($this->config);
 }
 /**
  * Override the Eloquent method to check the account is enabled.
  * @param mixed $id
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($id)
 {
     $user = parent::retrieveById($id);
     return $user ? $user->status ? $user : null : null;
 }
Beispiel #16
0
 public function __construct()
 {
     parent::__construct(new BcryptHasher(), 'User');
 }
 /**
  * {@inheritdoc}
  */
 public function retrieveByToken($identifier, $token)
 {
     $model = parent::retrieveByToken($identifier, $token);
     return $this->discoverAdldapFromModel($model);
 }
Beispiel #18
0
 /**
  * Create a new database user provider.
  *
  * @param  \Illuminate\Contracts\Hashing\Hasher $hasher
  * @param  string $model
  */
 public function __construct(HasherContract $hasher, $model)
 {
     parent::__construct($hasher, $model);
     $this->model = $model;
     $this->hasher = $hasher;
 }
 /**
  * Create a new Eloquent LDAP user provider.
  *
  * @param  array $ldapConfig
  * @param  \Illuminate\Contracts\Hashing\Hasher  $hasher
  * @param  string  $model
  * @return void
  */
 public function __construct($ldapConfig, HasherContract $hasher, $model)
 {
     parent::__construct($hasher, $model);
     $this->ldapConfig = $ldapConfig;
 }