Created
November 29, 2018 12:09
-
-
Save renepardon/540bd2224fda996f701d86301898b70b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function attemptLogin(Request $request) | |
{ | |
$guards = array_keys(config('auth.guards')); | |
$attempts = []; | |
foreach ($guards as $guard) { | |
$guardInstance = Auth::guard($guard); | |
if ($guardInstance instanceof TokenGuard) { | |
// No "API" authentication with this method | |
continue; | |
} | |
$credentials = $this->credentials($request); | |
// $attempts[$guard] = $guardInstance->attempt($credentials, $request->filled('remember')); | |
if ($guard == 'ldap') { | |
$ldap = app()->make(AdldapInterface::class); | |
$provider = $ldap->getDefaultProvider(); | |
$attempts[$guard] = $provider->auth()->attempt( | |
$credentials[$this->username()], | |
$credentials['password'], | |
true | |
); | |
} else { | |
$attempts[$guard] = $guardInstance->attempt($credentials, $request->filled('remember')); | |
} | |
} | |
return (bool)array_search(true, $attempts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment