added domain logic for permission checks (#1803)
This commit is contained in:
@@ -150,7 +150,6 @@ class Activity implements EntityWithMetaFields
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getMetaFields(): Collection
|
||||
|
||||
@@ -393,7 +393,6 @@ class Customer implements EntityWithMetaFields
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getMetaFields(): Collection
|
||||
|
||||
@@ -14,7 +14,6 @@ use Doctrine\Common\Collections\Collection;
|
||||
interface EntityWithMetaFields
|
||||
{
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getMetaFields(): Collection;
|
||||
|
||||
@@ -298,7 +298,6 @@ class Project implements EntityWithMetaFields
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getMetaFields(): Collection
|
||||
|
||||
@@ -509,7 +509,6 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getMetaFields(): Collection
|
||||
|
||||
@@ -354,6 +354,11 @@ class User extends BaseUser implements UserInterface
|
||||
$team->removeUser($this);
|
||||
}
|
||||
|
||||
public function hasTeamAssignment(): bool
|
||||
{
|
||||
return !$this->getTeams()->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<Team>
|
||||
*/
|
||||
@@ -372,6 +377,11 @@ class User extends BaseUser implements UserInterface
|
||||
return $team->getTeamLead() === $this;
|
||||
}
|
||||
|
||||
public function canSeeAllData(): bool
|
||||
{
|
||||
return $this->isSuperAdmin() || $this->isAdmin();
|
||||
}
|
||||
|
||||
public function isTeamlead(): bool
|
||||
{
|
||||
return $this->hasRole(static::ROLE_TEAMLEAD);
|
||||
|
||||
@@ -31,7 +31,7 @@ class AjaxAuthenticationSubscriber implements EventSubscriberInterface
|
||||
$request = $event->getRequest();
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
$exception = $event->getException();
|
||||
$exception = $event->getThrowable();
|
||||
if ($exception instanceof AuthenticationExpiredException) {
|
||||
$event->setResponse(new Response('Session expired', 403, ['Login-Required' => true]));
|
||||
} elseif ($exception instanceof AuthenticationException) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class TeamMemberType extends AbstractType
|
||||
/** @var User $user */
|
||||
$user = $options['user'];
|
||||
|
||||
if (null !== $user && !$user->getTeams()->isEmpty() && !$user->isSuperAdmin() && !$user->isAdmin()) {
|
||||
if (null !== $user && $user->hasTeamAssignment() && !$user->canSeeAllData()) {
|
||||
$qb
|
||||
->leftJoin('u.teams', 'teams')
|
||||
->leftJoin('teams.users', 'users')
|
||||
|
||||
@@ -122,7 +122,7 @@ class ActivityRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all activities
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class CustomerRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all customers
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class InvoiceRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all projects
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class ProjectRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all projects
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ class TeamRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all user
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ class TimesheetRepository extends EntityRepository
|
||||
}
|
||||
|
||||
// make sure that admins see all timesheet records
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ class UserRepository extends EntityRepository implements UserLoaderInterface
|
||||
}
|
||||
|
||||
// make sure that admins see all user
|
||||
if (null !== $user && ($user->isSuperAdmin() || $user->isAdmin())) {
|
||||
if (null !== $user && $user->canSeeAllData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user