public function auth(\Intro\Form\AuthForm $authForm)
 {
     $data = (object) $authForm->getData();
     $authRepo = $this->em->getRepository('Application\\Entity\\User');
     $result = $authRepo->findOneBy(array('zipcode' => $data->zipcode, 'firstname' => strtolower($data->firstname), 'houseNr' => $data->housenr));
     if ($result) {
         $phrase = rand(0, 9999999999);
         setcookie("id", $result->id, time() + 604800);
         setcookie("phrase", $phrase, time() + 604800);
         $result->phrase = $phrase;
         $this->em->persist($result);
         $this->em->flush();
         return true;
     }
     $this->wipeCookies();
     return false;
 }
 public function authAction()
 {
     // init
     $authForm = new AuthForm();
     $request = $this->getRequest();
     $messages = array();
     if ($request->isPost()) {
         $postData = $request->getPost();
         $authForm->setData($postData);
         if ($authForm->isValid()) {
             $messages = $authForm->getMessages();
             if ($this->auth->auth($authForm)) {
                 return $this->redirect()->toRoute('home');
             } else {
                 $messages[] = array('noUserFound' => 'Gebruiker niet gevonden, gegevens onjuist?');
             }
         }
     }
     // view
     return array('authForm' => $authForm, 'messages' => $messages);
 }