getSession() public method

{@inheritDoc}
public getSession ( )
コード例 #1
0
 /**
  * @test
  */
 public function getSession_objectInitialized_returnSession()
 {
     //Mock the Request object
     $session = $this->getMock("Symfony\\Component\\HttpFoundation\\Session\\SessionInterface");
     $this->request->expects($this->once())->method('getSession')->will($this->returnValue($session));
     $returnValue = $this->authContext->getSession();
     $this->assertEquals($session, $returnValue);
 }
コード例 #2
0
 /**
  * Ask for Google authentication code.
  *
  * @param AuthenticationContext $context
  *
  * @return Response|null
  */
 public function requestAuthenticationCode(AuthenticationContext $context)
 {
     $user = $context->getUser();
     $request = $context->getRequest();
     $session = $context->getSession();
     // Display and process form
     $authCode = $request->get($this->authCodeParameter);
     if ($authCode !== null) {
         if ($this->authenticator->checkCode($user, $authCode)) {
             $context->setAuthenticated(true);
             return new RedirectResponse($request->getUri());
         } else {
             $session->getFlashBag()->set('two_factor', 'scheb_two_factor.code_invalid');
         }
     }
     // Force authentication code dialog
     return $this->templating->renderResponse($this->formTemplate, array('useTrustedOption' => $context->useTrustedOption()));
 }
コード例 #3
0
 /**
  * requestAuthenticationCode
  * @param AuthenticationContext $context
  * @return \Symfony\Component\HttpFoundation\Response|null
  **/
 public function requestAuthenticationCode(AuthenticationContext $context)
 {
     $user = $context->getUser();
     $request = $context->getRequest();
     $session = $context->getSession();
     $authData = $request->get($this->authCodeParameter);
     if (null !== $authData) {
         if ($this->authenticator->checkRequest($user, json_decode($session->get('u2f_authentication')), json_decode($authData))) {
             $context->setAuthenticated(true);
             return new RedirectResponse($request->getUri());
         } else {
             $session->getFlashBag()->set('two_factor', 'r_u2f_two_factor.code_invalid');
         }
     }
     $authenticationData = json_encode($this->authenticator->generateRequest($user), JSON_UNESCAPED_SLASHES);
     $session->set('u2f_authentication', $authenticationData);
     return $this->templating->renderResponse($this->formTemplate, array('authenticationData' => $authenticationData, 'useTrustedOption' => $context->useTrustedOption()));
 }
コード例 #4
0
 public function requestAuthenticationCode(AuthenticationContext $context)
 {
     $user = $context->getUser();
     $request = $context->getRequest();
     $session = $context->getSession();
     // Display and process form
     $authCode = $request->get($this->authCodeParameter);
     if ($authCode !== null) {
         $result = $this->authenticator->checkCode($user, $authCode);
         if ($result) {
             //get the inwebo alias
             $alias = $result['alias'];
             //Persist the alias to the database to be used in case we do 2FA only once
             $this->codeHandler->getAndPersist($user, $alias);
             $context->setAuthenticated(true);
             return new RedirectResponse($request->getUri());
         } else {
             $session->getFlashBag()->set("two_factor", "scheb_two_factor.code_invalid");
         }
     }
     //die();
     // Force authentication code dialog
     return $this->templating->renderResponse($this->formTemplate, array('useTrustedOption' => $context->useTrustedOption()));
 }