Commit d0a15fc1 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix role assignment: sync role_id to pivot table on user create/edit

UserForm was setting role_id on the users table but not syncing to the
role_user pivot table. Permission checks use the pivot (roles() relation),
so users appeared to have the correct role in the UI but had zero
permissions in practice.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 435aeddb
......@@ -290,6 +290,11 @@ public function save(): void
$user = User::create($data);
}
// Sync role to pivot table
if ($this->role_id) {
$user->roles()->syncWithoutDetaching([$this->role_id]);
}
// Link person to user
if ($person && ! $person->user_id) {
$person->update(['user_id' => $user->id]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment