Right now when using non-Eloquent auth provider drivers, things can sometimes break when logging model events. For example, using a simple token guard driver and database provider driver, the logged in user is an instance of Illuminate\Auth\GenericUser. When model events get fired, the user is not an instance of Model and is also not null, so a TypeError gets thrown.
This change will make the default resolver more forgiving and will prevent a TypeError when the current user is not an instance of Model, while still maintaining the ability to override the causer using the normal means. Since Auth::user() (which is the the current logic of the default causer resolver) is meant to return an instance of Illuminate\Contracts\Auth\Authenticatable rather than Model, I think this is a reasonable fallback.
Right now when using non-Eloquent auth provider drivers, things can sometimes break when logging model events. For example, using a simple
token
guard driver anddatabase
provider driver, the logged in user is an instance ofIlluminate\Auth\GenericUser
. When model events get fired, the user is not an instance ofModel
and is also not null, so aTypeError
gets thrown.This change will make the default resolver more forgiving and will prevent a
TypeError
when the current user is not an instance ofModel
, while still maintaining the ability to override the causer using the normal means. SinceAuth::user()
(which is the the current logic of the default causer resolver) is meant to return an instance ofIlluminate\Contracts\Auth\Authenticatable
rather thanModel
, I think this is a reasonable fallback.