DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

If LDAP is offline, how can I authenticate using the database? #609

Closed wpsouto closed 8 months ago

wpsouto commented 8 months ago

When trying to authenticate and the user cannot be found or the LDAP is offline, how to authenticate with the user registered in the database?

stevebauman commented 8 months ago

Hi @wpsouto,

For this functionality you can use fallback authentication which involves adding a fallback array inside of the credentials sent through Auth::attempt(). These credentials get passed to the standard Laravel Eloquent authentication driver (notice the mail and the email array keys are different):

Auth::attempt([
    'mail' => $request->email,
    'password' => $request->password,
    'fallback' => [
        'email' => $request->email,
        'password' => $request->password,
    ],
]);