public function doRegisterAction()
 {
     if ($this->registerView->userPressedRegister()) {
         try {
             $registrationCredentials = $this->registerView->getRegistrationCredentials();
             if ($registrationCredentials == null) {
                 return;
             }
             $this->registerModel->registerUser($registrationCredentials);
             $this->registerView->setRegistrationSuccess();
         } catch (\common\UsernameTakenException $e) {
             $this->registerView->setRegistrationFailed();
         } catch (\Exception $e) {
             $this->registerView->setDatabaseError();
         }
     }
 }
 /**
  * Handle user input.
  */
 public function listen()
 {
     if ($this->regView->registerButtonPost()) {
         $username = $this->regView->getUsername();
         $password = $this->regView->getPassword();
         $passwordRepeat = $this->regView->getPasswordRepeat();
         try {
             if ($this->regModel->verifyRegisterCredentials($username, $password, $passwordRepeat)) {
                 $this->logView->setCookieUsername($this->regView->getUsername());
                 $this->regView->redirectToLogin();
             }
         } catch (RUsernameAndPasswordLengthException $e) {
             $this->regView->setMsgUsernameAndPasswordException();
         } catch (RPasswordLengthException $e) {
             $this->regView->setMsgPassWordLengthException();
         } catch (RUsernameLengthException $e) {
             $this->regView->setMsgUsernameLengthException();
         } catch (RPasswordMismatchException $e) {
             $this->regView->setMsgPasswordMismatchException();
         } catch (RUserExistsException $e) {
             $this->regView->setMsgUserExistsException();
         } catch (RInvalidCharactersException $e) {
             $this->regView->setMsgInvalidCharacterException();
         }
     }
 }