Auto commit for release 'develop' on 2025-02-10

This commit is contained in:
github-actions
2025-02-10 04:10:23 +01:00
parent 41ad35880d
commit 57ec9b8e36
22 changed files with 44 additions and 38 deletions

View File

@@ -48,11 +48,13 @@ trait UserGroupTrait
public function checkUserGroupAccess(UserRoleEnum $role): bool
{
$result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role);
if($result) {
if ($result) {
Log::debug(sprintf('User #%d has role %s in group #%d or is owner/full.', $this->user->id, $role->value, $this->userGroup->id));
return true;
}
Log::warning(sprintf('User #%d DOES NOT have role %s in group #%d.', $this->user->id, $role->value, $this->userGroup->id));
return false;
}
@@ -62,7 +64,7 @@ trait UserGroupTrait
public function setUserGroup(UserGroup $userGroup): void
{
if (null === $this->user) {
Log::warning(sprintf('User is not set in repository %s', get_class($this)));
Log::warning(sprintf('User is not set in repository %s', static::class));
}
$this->userGroup = $userGroup;
}
@@ -70,16 +72,18 @@ trait UserGroupTrait
/**
* @throws FireflyException
*/
public function setUser(null | Authenticatable | User $user): void
public function setUser(null|Authenticatable|User $user): void
{
if ($user instanceof User) {
$this->user = $user;
$this->user = $user;
if (null === $user->userGroup) {
throw new FireflyException(sprintf('User #%d has no user group.', $user->id));
}
$this->userGroup = $user->userGroup;
return;
}
throw new FireflyException(sprintf('Object is of class %s, not User.', get_class($user)));
}
@@ -89,14 +93,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));
}