Ejemplo n.º 1
0
 /**
  *  Logs in customer.
  */
 public function execute()
 {
     $user = $this->userDAO->getByUserEmail($this->request->getPost('email'));
     try {
         if (!$user->getEmail()) {
             throw new \Exception('User with specified email does not exist.');
         }
         $isPasswordVerified = $this->userService->verify($this->request->getPost('password'), $user->getUserPassword());
         if (!$isPasswordVerified) {
             throw new \Exception('Invalid username/password. Check your credentials.');
         }
         $this->userService->verify($this->request->getPost('password'), $user->getUserPassword());
         Session::setMessage('You have successfully logged in!');
         Session::set('username', $user->getUserName());
         $this->response->redirect('/');
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
Ejemplo n.º 2
0
 /**
  * Validates user input.
  */
 private function validate() : bool
 {
     $password = trim($this->request->getPost('password'));
     $confirm = trim($this->request->getPost('password_confirm'));
     return $password == $confirm;
 }