Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

BindsLdapUserModel - Laravel 5.8 #696

Closed
andrefigueira93 wants to merge 2 commits into master from v5.0
Closed

BindsLdapUserModel - Laravel 5.8 #696

andrefigueira93 wants to merge 2 commits into master from v5.0

Conversation

@andrefigueira93
Copy link

@andrefigueira93 andrefigueira93 commented Mar 21, 2019
edited
Loading

File Being Edited => Adldap\Laravel\Listeners\BindsLdapUserModel

In Laravel 5.8 i have had to change from

public function handle($event)
 {
 if (
 $this->isUsingAdldapProvider($event->guard)
 && $this->canBind($event->user)
 && $user = Resolver::byModel($event->user)
 ) {
 $event->user->setLdapUser($user);
 }
 }
 protected function isUsingAdldapProvider($guard) : bool
 {
 return Auth::guard($guard)->getProvider() instanceof DatabaseUserProvider;
 }

to

public function handle($event)
 {
 if (
 $this->isUsingAdldapProvider()
 && $this->canBind($event->user)
 && $user = Resolver::byModel($event->user)
 ) {
 $event->user->setLdapUser($user);
 }
 }
 protected function isUsingAdldapProvider() : bool
 {
 return Auth::guard()->getProvider() instanceof DatabaseUserProvider;
 }

Unique way that works

@andrefigueira93 andrefigueira93 changed the title (削除) V5.0 (削除ここまで) (追記) V10.0 (追記ここまで) Mar 21, 2019
@andrefigueira93 andrefigueira93 changed the title (削除) V10.0 (削除ここまで) (追記) BindsLdapUserModel - Laravel 5.8 (追記ここまで) Mar 21, 2019
Copy link
Member

Hi @andrefigueira93, I don't think this change would resolve the issue you're having.

The Authenticated and Login events both have the $guard property set to the name of the guard that your user is authenticated with. This property allows us to locate the correct guard and ensure you're using an Adldap2 provider with it so no exceptions are generated.

Authenticated Event:
https://github.com/laravel/framework/blob/cd7486a4355be57e8928f89048a25f30883f202f/src/Illuminate/Auth/Events/Authenticated.php#L16

Login Event:
https://github.com/laravel/framework/blob/cd7486a4355be57e8928f89048a25f30883f202f/src/Illuminate/Auth/Events/Login.php#L16

What is the guard property set to on the Login and Authenticated events?

Copy link
Author

andrefigueira93 commented Mar 21, 2019
edited
Loading

Reproduction of the error
Captura de Tela 2019年03月21日 às 11 32 52

The problem is here -> dd($event)
Captura de Tela 2019年03月21日 às 11 36 36

The $event doesn't have the ->guard property.

Auth::guard()->getProvider() instanceof DatabaseUserProvider is enough to verify.

Copy link
Member

Strange, are you sure you're using Laravel 5.8?

This is definitely a bug though, I thought the $guard property was available for Laravel 5.5 or greater, but it's only available on Laravel 5.7 or greater.

Going to patch this now, thanks @andrefigueira93!

Copy link
Author

Tried in 5.6, 5.7 and 5.8 =/ all of them are reproducing this error =/

You're welcome! I'm here to help =)

Copy link
Member

Are you sure you're using those versions? I'm using v6.0 model binding in 5.7 and 5.8 and don't receive this exception.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /