Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function tryToRegister()
- {
- if ($this->registerView->userClicksRegister()) {
- try {
- $regCredentials = $this->registerView->checkUser();
- $this->registerUser($regCredentials);
- } catch (\UsernameEmpty $e) {
- $this->registerView->setMessage('Username has too few characters, at least 3 characters.');
- } catch (\PasswordEmpty $e) {
- $this->registerView->setMessage('Password has too few characters, at least 6 characters.');
- } catch (\UsernameAndPasswordEmpty $e) {
- $this->registerView->setMessage('Username has too few characters, at least 3 characters. <br> Password has too few characters, at least 6 characters.');
- } catch (\PasswordDoesNotMatch $e) {
- $this->registerView->setMessage('Passwords do not match.');
- } catch (\UserAlreadyExist $e) {
- $this->registerView->setMessage('User exists, pick another username.');
- } catch (\ContainsHTML $e) {
- $this->registerView->setMessage('Username contains invalid characters.');
- }
- }
- }
- public function registerUser($credentials)
- {
- if (!$this->auth->doesUserExist($credentials)) {
- $this->auth->register($credentials);
- $this->storage->saveRegisterMessage('Registered new user.');
- header("Location: ?");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement