detail pages for customers and projects (#1371)

This commit is contained in:
Kevin Papst
2020-01-16 16:25:28 +01:00
committed by GitHub
parent 28c5357f11
commit 6a44dbfe83
131 changed files with 3055 additions and 1742 deletions

View File

@@ -15,25 +15,22 @@ use App\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* A voter to check permissions on Customers.
* A voter to check authorization on Customers.
*/
class CustomerVoter extends AbstractVoter
{
public const VIEW = 'view';
public const EDIT = 'edit';
public const BUDGET = 'budget';
public const DELETE = 'delete';
public const PERMISSIONS = 'permissions';
/**
* support rules based on the given $subject (here: Customer)
* supported attributes/rules based on the given customer
*/
public const ALLOWED_ATTRIBUTES = [
self::VIEW,
self::EDIT,
self::BUDGET,
self::DELETE,
self::PERMISSIONS,
'view',
'create',
'edit',
'budget',
'delete',
'permissions',
'comments',
'details',
];
/**
@@ -72,6 +69,11 @@ class CustomerVoter extends AbstractVoter
return true;
}
// those cannot be assigned to teams
if (in_array($attribute, ['create', 'delete'])) {
return false;
}
$hasTeamleadPermission = $this->hasRolePermission($user, $attribute . '_teamlead_customer');
$hasTeamPermission = $this->hasRolePermission($user, $attribute . '_team_customer');