SHARE
TWEET

Untitled

a guest Oct 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function tryToRegister()
  2.   {
  3.     if ($this->registerView->userClicksRegister()) {
  4.       try {
  5.         $regCredentials = $this->registerView->checkUser();
  6.         $this->registerUser($regCredentials);
  7.       } catch (\UsernameEmpty $e) {
  8.         $this->registerView->setMessage('Username has too few characters, at least 3 characters.');
  9.       } catch (\PasswordEmpty $e) {
  10.         $this->registerView->setMessage('Password has too few characters, at least 6 characters.');
  11.       } catch (\UsernameAndPasswordEmpty $e) {
  12.         $this->registerView->setMessage('Username has too few characters, at least 3 characters. <br> Password has too few characters, at least 6 characters.');
  13.       } catch (\PasswordDoesNotMatch $e) {
  14.         $this->registerView->setMessage('Passwords do not match.');
  15.       } catch (\UserAlreadyExist $e) {
  16.         $this->registerView->setMessage('User exists, pick another username.');
  17.       } catch (\ContainsHTML $e) {
  18.         $this->registerView->setMessage('Username contains invalid characters.');
  19.       }
  20.     }
  21.   }
  22.  
  23.   public function registerUser($credentials)
  24.   {
  25.     if (!$this->auth->doesUserExist($credentials)) {
  26.       $this->auth->register($credentials);
  27.       $this->storage->saveRegisterMessage('Registered new user.');
  28.       header("Location: ?");
  29.     }
  30.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top