Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@

namespace Hackzilla\Bundle\TicketBundle\Manager;

use Doctrine\ORM\EntityRepository;
use Doctrine\Common\Persistence\ObjectRepository;
use Hackzilla\Bundle\TicketBundle\Model\TicketInterface;
use Hackzilla\Bundle\TicketBundle\Model\UserInterface;
use Hackzilla\Bundle\TicketBundle\TicketRole;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

class UserManager implements UserManagerInterface
{
/**
* @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
* @var TokenStorageInterface
*/
private $tokenStorage;

/**
* @var \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
* @var AuthorizationCheckerInterface
*/
private $authorizationChecker;

/**
* @var \Doctrine\ORM\EntityRepository
* @var ObjectRepository
*/
private $userRepository;

/**
* @param TokenStorage $tokenStorage
* @param TokenStorageInterface $tokenStorage
* @param ObjectRepository $userRepository
* @param AuthorizationCheckerInterface $authorizationChecker
* @param EntityRepository $userRepository
*/
public function __construct(
TokenStorage $tokenStorage,
EntityRepository $userRepository,
TokenStorageInterface $tokenStorage,
ObjectRepository $userRepository,
AuthorizationCheckerInterface $authorizationChecker
) {
$this->tokenStorage = $tokenStorage;
Expand Down Expand Up @@ -66,9 +67,7 @@ public function getUserById($userId)
return;
}

$user = $this->userRepository->find($userId);

return $user;
return $this->userRepository->find($userId);
}

/**
Expand All @@ -85,8 +84,8 @@ public function hasRole(UserInterface $user, $role)
}

/**
* @param \Hackzilla\Bundle\TicketBundle\Model\UserInterface|string $user
* @param TicketInterface $ticket
* @param UserInterface|string $user
* @param TicketInterface $ticket
*/
public function hasPermission($user, TicketInterface $ticket)
{
Expand All @@ -95,7 +94,7 @@ public function hasPermission($user, TicketInterface $ticket)
TicketRole::ADMIN
) && $ticket->getUserCreated() != $user->getId())
) {
throw new \Symfony\Component\HttpKernel\Exception\HttpException(403);
throw new AccessDeniedHttpException();
}
}
}