Skip to content

Commit

Permalink
Collect existing roles/groups before merging the new ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Dec 17, 2024
1 parent 5082192 commit 794d7c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Auth/File/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function explicitRoles($roles = null)

public function assignRole($role)
{
$roles = collect(Arr::wrap($role))
$roles = collect($this->get('roles', []))
->merge(Arr::wrap($role))
->map(fn ($role) => is_string($role) ? $role : $role->handle())
->merge($this->get('roles', []))
->unique()
->all();

Expand All @@ -200,9 +200,9 @@ public function removeRole($role)

public function addToGroup($group)
{
$groups = collect(Arr::wrap($group))
$groups = collect($this->get('groups', []))
->merge(Arr::wrap($group))
->map(fn ($group) => is_string($group) ? $group : $group->handle())
->merge($this->get('groups', []))
->unique()
->all();

Expand Down

0 comments on commit 794d7c0

Please sign in to comment.