mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-11 07:10:48 +00:00
🤖 Auto commit for release 'develop' on 2025-09-26
This commit is contained in:
@@ -61,10 +61,10 @@ trait UserGroupTrait
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setUser(Authenticatable | User | null $user): void
|
||||
public function setUser(Authenticatable|User|null $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
if (null === $user->userGroup) {
|
||||
throw new FireflyException(sprintf('User #%d ("%s") has no user group.', $user->id, $user->email));
|
||||
}
|
||||
@@ -99,14 +99,15 @@ trait UserGroupTrait
|
||||
public function setUserGroupById(int $userGroupId): void
|
||||
{
|
||||
$memberships = GroupMembership::where('user_id', $this->user->id)
|
||||
->where('user_group_id', $userGroupId)
|
||||
->count();
|
||||
->where('user_group_id', $userGroupId)
|
||||
->count()
|
||||
;
|
||||
if (0 === $memberships) {
|
||||
throw new FireflyException(sprintf('User #%d has no access to administration #%d', $this->user->id, $userGroupId));
|
||||
}
|
||||
|
||||
/** @var null|UserGroup $userGroup */
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
if (null === $userGroup) {
|
||||
throw new FireflyException(sprintf('Cannot find administration for user #%d', $this->user->id));
|
||||
}
|
||||
|
Reference in New Issue
Block a user