Beispiel #1
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;
 }
 /**
  * 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;
 }
 /**
  * {@inheritdoc}
  */
 public function retrieveByCredentials(array $credentials)
 {
     if ($user = parent::retrieveByCredentials($credentials)) {
         return $user;
     }
     $credStr = $this->getCredentialsString($credentials);
     throw new AuthenticationException("No user with these credentials found - {$credStr}");
 }
 /**
  * {@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;
 }
 /**
  * {@inheritdoc}
  */
 public function retrieveByCredentials(array $credentials)
 {
     $user = $this->retrieveLdapUserByCredentials($credentials);
     // We need to check if we have the right user instance, as well
     // as set the currently authenticated user in this case.
     if ($user instanceof User && ($this->user = $user)) {
         // We'll retrieve the login name from the LDAP user.
         $username = $this->getLoginUsernameFromUser($user);
         // Then, get their password from the given credentials.
         $password = $this->getPasswordFromCredentials($credentials);
         // Perform LDAP authentication.
         if ($this->authenticate($username, $password)) {
             // Passed, create / find the eloquent model from our Adldap user.
             $model = $this->getModelFromAdldap($user, $password);
             if (method_exists($model, 'trashed') && $model->trashed()) {
                 // If the model is soft-deleted, we'll fire an event
                 // with the affected LDAP user and their model.
                 $this->handleAuthenticatedModelTrashed($user, $model);
                 // We also won't allow soft-deleted users to authenticate.
                 return;
             }
             if ($this->getOnlyAllowImportedUsers() && !$model->exists) {
                 // If we're only allowing already imported users
                 // and the user doesn't exist, we won't
                 // allow them to authenticate.
                 return;
             }
             return $model;
         }
     }
     if ($this->getLoginFallback()) {
         // Login failed. If login fallback is enabled
         // we'll call the eloquent driver.
         return parent::retrieveByCredentials($credentials);
     }
 }
 /**
  * [retrieveByEloquentCredentials description].
  *
  * @param array $credentials [description]
  *
  * @return [type] [description]
  */
 public function retrieveByEloquentCredentials(array $credentials)
 {
     return parent::retrieveByCredentials($credentials);
 }
 /**
  * Override the Eloquent method to check the account is enabled.
  * @param array $credentials
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     // Add the status requirement to credentials
     return parent::retrieveByCredentials($credentials + ['status' => 1]);
 }