Changeset View
Changeset View
Standalone View
Standalone View
src/app/Auth/LDAPUserProvider.php
Show All 20 Lines | class LDAPUserProvider extends EloquentUserProvider implements UserProvider | ||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null | * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||||
*/ | */ | ||||
public function retrieveById($identifier) | public function retrieveById($identifier) | ||||
{ | { | ||||
return parent::retrieveById($identifier); | return parent::retrieveById($identifier); | ||||
} | } | ||||
/** | /** | ||||
* Retrieve the user by its credentials. | * Retrieve the user by its credentials (email). | ||||
* | |||||
* Please note that this function also validates the password. | |||||
* | * | ||||
* @param array $credentials An array containing the email and password. | * @param array $credentials An array containing the email and password. | ||||
* | * | ||||
* @return User|null | * @return User|null | ||||
*/ | */ | ||||
public function retrieveByCredentials(array $credentials) | public function retrieveByCredentials(array $credentials) | ||||
{ | { | ||||
$entries = User::where('email', '=', $credentials['email']); | $entries = User::where('email', '=', $credentials['email'])->get(); | ||||
$count = $entries->count(); | $count = $entries->count(); | ||||
if ($count == 1) { | if ($count == 1) { | ||||
$user = $entries->select(['id', 'email', 'password', 'password_ldap'])->first(); | return $entries->first(); | ||||
if (!$this->validateCredentials($user, $credentials)) { | |||||
return null; | |||||
} | |||||
return $user; | |||||
} | } | ||||
if ($count > 1) { | if ($count > 1) { | ||||
\Log::warning("Multiple entries for {$credentials['email']}"); | \Log::warning("Multiple entries for {$credentials['email']}"); | ||||
} else { | } else { | ||||
\Log::warning("No entries for {$credentials['email']}"); | \Log::warning("No entries for {$credentials['email']}"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |