-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hi.
I found a bug in version 3.1.0 (latest). Don't know if this was on old releases as well.
The issue is with column "created_by".
This column in DB is filled only when default guard === nova guard for auth :) I had different for frontend and different for nova and that's why I found this issue.
In Models/Note.php you have:
public function createdBy()
{
$provider = 'users';
if (config('nova.guard')) $provider = config('auth.guards.' . config('nova.guard') . '.provider');
$userClass = config('auth.providers.' . $provider . '.model');
return $this->belongsTo($userClass, 'created_by');
}
which is OK but then under trait HasNotes you are using:
$user = $user ? Auth::user() : null;
return $this->notes()->create([
'text' => $note,
'created_by' => isset($user) ? $user->id : null,
'system' => $system,
]);
Without providing guard Auth is returning default, in my case it was api while nova auth was web. It should be rather Auth::guard(config('nova.guard'))->user()
Steps to reproduce:
- Install nova project
- change config => nova.guard to web
- change config => auth.defaults.guard to API (must use different table than web guard probably)
- Try to save note (it will appear as "User" instead of your nova user data)
DarAzizi
Metadata
Metadata
Assignees
Labels
No labels