Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit c47ab49

Browse files
committed
Fixed potential bug with default guard being used
1 parent 8766e2c commit c47ab49

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Listeners/BindsLdapUserModel.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Adldap\Laravel\Listeners;
44

5-
use Adldap\Laravel\Auth\Provider;
65
use Adldap\Laravel\Facades\Resolver;
76
use Adldap\Laravel\Traits\HasLdapUser;
7+
use Adldap\Laravel\Auth\DatabaseUserProvider;
88
use Illuminate\Support\Facades\Auth;
99
use Illuminate\Contracts\Auth\Authenticatable;
1010

@@ -13,7 +13,7 @@ class BindsLdapUserModel
1313
/**
1414
* Binds the LDAP user record to their model.
1515
*
16-
* @param mixed $event
16+
* @param \Illuminate\Auth\Events\Login|\Illuminate\Auth\Events\Authenticated $event
1717
*
1818
* @return void
1919
*/
@@ -23,7 +23,7 @@ public function handle($event)
2323
// Adldap authentication provider, the required trait, and the
2424
// users LDAP property has not already been set.
2525
if (
26-
$this->isUsingAdldapProvider()
26+
$this->isUsingAdldapProvider($event->guard)
2727
&& $this->canBind($event->user)
2828
&& is_null($event->user->ldap)
2929
) {
@@ -36,11 +36,13 @@ public function handle($event)
3636
/**
3737
* Determines if the Auth Provider is an instance of the Adldap Provider.
3838
*
39+
* @param string $guard
40+
*
3941
* @return bool
4042
*/
41-
protected function isUsingAdldapProvider() : bool
43+
protected function isUsingAdldapProvider($guard) : bool
4244
{
43-
return Auth::getProvider() instanceof Provider;
45+
return Auth::guard($guard)->getProvider() instanceof DatabaseUserProvider;
4446
}
4547

4648
/**

0 commit comments

Comments
 (0)