public function httpPostMethod(Http $http, array $formFields) { if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) { $CustomerModel = new CustomerModel(); $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password']); //var_dump($user_id); if (ctype_digit($user_id)) { $user = $CustomerModel->findCustomer($user_id); $UserSession = new UserSession(); $UserSession->create($user); $http->redirectTo('/'); } else { $http->redirectTo('Exception?' . $user_id); } } else { $http->redirectTo('Exception?Error=4'); } }
public function httpPostMethod(Http $http, array $formFields) { if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) { try { $userSession = new UserSession(); $CustomerModel = new CustomerModel(); $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password'], $_SERVER['REMOTE_ADDR']); if (ctype_digit($user_id)) { $user = $CustomerModel->findCustomer($user_id); $userSession->create($user); $http->redirectTo('/'); } } catch (DomainException $event) { //var_dump($event); $form = new LoginForm(); $form->bind($formFields); $form->setErrorMessage($event->getMessage()); return ['_form' => $form]; //AVEC CONTROLEUR EXECPTION --- $http->redirectTo('Exception?'.$user_id); } } else { $http->redirectTo('Exception?Error=4'); } }