From 5621115103c4d1d6f2d3058c7f80392334ff2979 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:29:16 +0200 Subject: [PATCH] Ensure default group is owned by the provided user --- app/Services/GroupService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Services/GroupService.php b/app/Services/GroupService.php index efde2d43..38c7aafa 100644 --- a/app/Services/GroupService.php +++ b/app/Services/GroupService.php @@ -15,6 +15,7 @@ class GroupService * Assign one or more accounts to a group * * @param array|int $ids accounts ids to assign + * @param User $user The user who owns the accounts & the target group * @param mixed $targetGroup The group the accounts should be assigned to * * @throws \Illuminate\Auth\Access\AuthorizationException @@ -109,6 +110,8 @@ class GroupService { $id = $user->preferences['defaultGroup'] === -1 ? (int) $user->preferences['activeGroup'] : (int) $user->preferences['defaultGroup']; - return Group::find($id); + return Group::where('id', $id) + ->where('user_id', $user->id) + ->first(); } }