| @@ 30-68 (lines=39) @@ | ||
| 27 | use Symfony\Component\HttpFoundation\Request; |
|
| 28 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 29 | ||
| 30 | class UnverifiedSecondFactorController extends Controller |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @var SecondFactorService |
|
| 34 | */ |
|
| 35 | private $secondFactorService; |
|
| 36 | ||
| 37 | public function __construct(SecondFactorService $secondFactorService) |
|
| 38 | { |
|
| 39 | $this->secondFactorService = $secondFactorService; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function getAction($id) |
|
| 43 | { |
|
| 44 | $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS']); |
|
| 45 | ||
| 46 | $secondFactor = $this->secondFactorService->findUnverified(new SecondFactorId($id)); |
|
| 47 | ||
| 48 | if ($secondFactor === null) { |
|
| 49 | throw new NotFoundHttpException(sprintf("Unverified second factor '%s' does not exist", $id)); |
|
| 50 | } |
|
| 51 | ||
| 52 | return new JsonResponse($secondFactor); |
|
| 53 | } |
|
| 54 | ||
| 55 | public function collectionAction(Request $request) |
|
| 56 | { |
|
| 57 | $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS']); |
|
| 58 | ||
| 59 | $query = new UnverifiedSecondFactorQuery(); |
|
| 60 | $query->identityId = $request->get('identityId'); |
|
| 61 | $query->verificationNonce = $request->get('verificationNonce'); |
|
| 62 | $query->pageNumber = (int) $request->get('p', 1); |
|
| 63 | ||
| 64 | $paginator = $this->secondFactorService->searchUnverifiedSecondFactors($query); |
|
| 65 | ||
| 66 | return JsonCollectionResponse::fromPaginator($paginator); |
|
| 67 | } |
|
| 68 | } |
|
| 69 | ||
| @@ 30-67 (lines=38) @@ | ||
| 27 | use Symfony\Component\HttpFoundation\Request; |
|
| 28 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 29 | ||
| 30 | class VettedSecondFactorController extends Controller |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @var SecondFactorService |
|
| 34 | */ |
|
| 35 | private $secondFactorService; |
|
| 36 | ||
| 37 | public function __construct(SecondFactorService $secondFactorService) |
|
| 38 | { |
|
| 39 | $this->secondFactorService = $secondFactorService; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function getAction($id) |
|
| 43 | { |
|
| 44 | $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS']); |
|
| 45 | ||
| 46 | $secondFactor = $this->secondFactorService->findVetted(new SecondFactorId($id)); |
|
| 47 | ||
| 48 | if ($secondFactor === null) { |
|
| 49 | throw new NotFoundHttpException(sprintf("Vetted second factor '%s' does not exist", $id)); |
|
| 50 | } |
|
| 51 | ||
| 52 | return new JsonResponse($secondFactor); |
|
| 53 | } |
|
| 54 | ||
| 55 | public function collectionAction(Request $request) |
|
| 56 | { |
|
| 57 | $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS']); |
|
| 58 | ||
| 59 | $query = new VettedSecondFactorQuery(); |
|
| 60 | $query->identityId = $request->get('identityId'); |
|
| 61 | $query->pageNumber = (int) $request->get('p', 1); |
|
| 62 | ||
| 63 | $paginator = $this->secondFactorService->searchVettedSecondFactors($query); |
|
| 64 | ||
| 65 | return JsonCollectionResponse::fromPaginator($paginator); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||