mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
🤖 Auto commit for release 'develop' on 2025-09-26
This commit is contained in:
@@ -37,7 +37,7 @@ interface UserGroupInterface
|
||||
|
||||
public function getUserGroup(): ?UserGroup;
|
||||
|
||||
public function setUser(Authenticatable | User | null $user): void;
|
||||
public function setUser(Authenticatable|User|null $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
|
@@ -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