Ejemplo n.º 1
0
 /**
  * Saves the supplied user to the database
  *
  * @param UserVO $userVO
  * @throws \Exception
  */
 public function save(UserVO $userVO)
 {
     $params = ['email' => $userVO->getEmail(), 'user_name' => $userVO->getUserName(), 'user_password' => $userVO->getUserPassword()];
     $request = $this->queryBuilder->insert(self::TABLE)->values($params);
     if (!$request->execute($params)) {
         throw new \Exception('User cannot be saved');
     }
 }
Ejemplo n.º 2
0
 /**
  *  Validates user input in Register form and saves customer into database.
  */
 public function execute()
 {
     $this->userVO->setEmail($this->request->getPost('email'));
     $this->userVO->setUserName($this->request->getPost('username'));
     $this->userVO->setUserPassword($this->userService->hashPassword($this->request->getPost('password')));
     if ($this->validate()) {
         try {
             $this->userDAO->save($this->userVO);
             UserVO::setMessage('Thank you for registering on our website!');
             Session::set('username', $this->userVO->getUserName());
             $this->response->redirect('/');
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     } else {
         throw new \Exception('Password and Confirm Password fields should be the same.');
     }
 }