mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Clean up code.
This commit is contained in:
@@ -31,15 +31,15 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
||||
interface UserGroupInterface
|
||||
{
|
||||
public function getUserGroup(): ?UserGroup;
|
||||
public function checkUserGroupAccess(UserRoleEnum $role): bool;
|
||||
|
||||
public function getUser(): ?User;
|
||||
|
||||
public function checkUserGroupAccess(UserRoleEnum $role): bool;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
public function getUserGroup(): ?UserGroup;
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
public function setUserGroupById(int $userGroupId): void;
|
||||
}
|
||||
|
@@ -40,16 +40,6 @@ trait UserGroupTrait
|
||||
protected ?User $user = null;
|
||||
protected ?UserGroup $userGroup = null;
|
||||
|
||||
public function getUserGroup(): ?UserGroup
|
||||
{
|
||||
return $this->userGroup;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function checkUserGroupAccess(UserRoleEnum $role): bool
|
||||
{
|
||||
$result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role);
|
||||
@@ -63,15 +53,9 @@ trait UserGroupTrait
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO This method does not check if the user has access to this particular user group.
|
||||
*/
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
public function getUser(): ?User
|
||||
{
|
||||
if (null === $this->user) {
|
||||
Log::warning(sprintf('User is not set in repository %s', static::class));
|
||||
}
|
||||
$this->userGroup = $userGroup;
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,6 +76,22 @@ trait UserGroupTrait
|
||||
throw new FireflyException(sprintf('Object is of class %s, not User.', $user::class));
|
||||
}
|
||||
|
||||
public function getUserGroup(): ?UserGroup
|
||||
{
|
||||
return $this->userGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO This method does not check if the user has access to this particular user group.
|
||||
*/
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
if (null === $this->user) {
|
||||
Log::warning(sprintf('User is not set in repository %s', static::class));
|
||||
}
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user