/**
  * @Route("/{userType}")
  * @Method({"POST"})
  *
  * @param Request $request
  *
  * @return Response
  */
 public function indexAction(Request $request, $userType)
 {
     // Generate a MAC value
     $mac = $this->macManager->generate()->getMac();
     // Cache the posted data using the MAC as its reference
     $this->cachePostedData($request, $mac);
     // Construct the response
     $response = array('url' => $this->getHandoffUrl($request, $userType, $mac));
     // Return a json encoded handoff url
     return new Response(json_encode($response, JSON_UNESCAPED_SLASHES));
 }
 /**
  * Triggered on every request.
  *
  * @param GetResponseEvent $event
  *
  * @return void
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     // do nothing if this is not an attempted landlord login
     if (!$request->request->has('landlord_login_submit')) {
         return;
     }
     if (($mac = $this->macManager->getFromSession()) === null) {
         throw new InvalidMacException('No MAC stored in the session');
     }
     if ($this->cache->fetch('mac-' . $mac) === false) {
         throw new InvalidMacException('Doctrine cache has expired');
     }
 }