Login for other models triggers listener BadMethodCallException
colinmackinlay opened this issue · 0 comments
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?