-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
030c84b
commit 2cfd44d
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Controller/VerificationController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Controller; | ||
|
||
use LoginCidadao\CoreBundle\Model\PersonInterface; | ||
use PROCERGS\LoginCidadao\CpfVerificationBundle\Exception\CpfVerificationException; | ||
use PROCERGS\LoginCidadao\CpfVerificationBundle\Model\SelectMotherInitialsChallenge; | ||
use PROCERGS\LoginCidadao\CpfVerificationBundle\Service\CpfVerificationService; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; | ||
|
||
/** | ||
* Class VerificationController | ||
* @package PROCERGS\LoginCidadao\CpfVerificationBundle\Controller | ||
* @codeCoverageIgnore | ||
*/ | ||
class VerificationController extends Controller | ||
{ | ||
/** | ||
* @Route("/cpf-verification", name="cpf_verification_verify") | ||
* @return Response | ||
*/ | ||
public function verifyAction() | ||
{ | ||
/** @var PersonInterface $person */ | ||
$person = $this->getUser(); | ||
|
||
/** @var CpfVerificationService $service */ | ||
$service = $this->get('procergs.nfg.cpf_verification.service'); | ||
try { | ||
dump($challenge = $service->selectChallenge(new SelectMotherInitialsChallenge(2, $person->getCpf(), []))); | ||
dump($service->listAvailableChallenges($person->getCpf())); | ||
dump($service->answerChallenge($challenge, 'X')); | ||
} catch (CpfVerificationException|TooManyRequestsHttpException $e) { | ||
dump($e); | ||
} | ||
|
||
return new Response('ok'); | ||
} | ||
} |