Changeset View
Changeset View
Standalone View
Standalone View
src/app/Auth/LDAPUserProvider.php
Show All 16 Lines | class LDAPUserProvider extends EloquentUserProvider implements UserProvider | ||||
* Retrieve the user by its credentials (email). | * Retrieve the user by its credentials (email). | ||||
* | * | ||||
* @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'])->get(); | $entries = User::where('email', \strtolower($credentials['email']))->get(); | ||||
$count = $entries->count(); | $count = $entries->count(); | ||||
if ($count == 1) { | if ($count == 1) { | ||||
return $entries->first(); | return $entries->first(); | ||||
} | } | ||||
if ($count > 1) { | if ($count > 1) { | ||||
Show All 12 Lines | class LDAPUserProvider extends EloquentUserProvider implements UserProvider | ||||
* @param array $credentials The credentials. | * @param array $credentials The credentials. | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function validateCredentials(Authenticatable $user, array $credentials): bool | public function validateCredentials(Authenticatable $user, array $credentials): bool | ||||
{ | { | ||||
$authenticated = false; | $authenticated = false; | ||||
if ($user->email == $credentials['email']) { | if ($user->email === \strtolower($credentials['email'])) { | ||||
if (!empty($user->password)) { | if (!empty($user->password)) { | ||||
if (Hash::check($credentials['password'], $user->password)) { | if (Hash::check($credentials['password'], $user->password)) { | ||||
$authenticated = true; | $authenticated = true; | ||||
} | } | ||||
} elseif (!empty($user->password_ldap)) { | } elseif (!empty($user->password_ldap)) { | ||||
if (substr($user->password_ldap, 0, 6) == "{SSHA}") { | if (substr($user->password_ldap, 0, 6) == "{SSHA}") { | ||||
$salt = substr(base64_decode(substr($user->password_ldap, 6)), 20); | $salt = substr(base64_decode(substr($user->password_ldap, 6)), 20); | ||||
Show All 39 Lines |