Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login for other models triggers listener BadMethodCallException #58

Open
colinmackinlay opened this issue Jul 29, 2022 · 0 comments
Open

Comments

@colinmackinlay
Copy link

I have three different models that can login to my application: Users, Applications, Enrolments. They are completely different models as they do completely different things. All start like this:

class User extends Authenticatable implements MustVerifyEmail

class Application extends Authenticatable implements MustVerifyEmail

class Enrolment extends Authenticatable implements MustVerifyEmail

but only User has use AuthenticationLoggable;

When an Application or an Enrolment logs in the Login event is triggered and the rappasoft listener Rappasoft\LaravelAuthenticationLog\Listeners\LoginListener::handle responds to it and fails:

$user = $event->user;
$ip = $this->request->ip();
$userAgent = $this->request->userAgent();
$known = $user->authentications()->whereIpAddress($ip)->whereUserAgent($userAgent)->whereLoginSuccessful(true)->first();
$newUser = Carbon::parse($user->{$user->getCreatedAtColumn()})->diffInMinutes(Carbon::now()) < 1;

i.e. when $known = $user->authentications() is called.

I think the listener should stop responding if the user model doesn't use AuthenticationLoggable

Could be the problem in #33 too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant