Skip to content

Instantly share code, notes, and snippets.

@renepardon
Created November 29, 2018 12:09
Show Gist options
  • Save renepardon/540bd2224fda996f701d86301898b70b to your computer and use it in GitHub Desktop.
Save renepardon/540bd2224fda996f701d86301898b70b to your computer and use it in GitHub Desktop.
<?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