diff --git a/public/static/js/signup.js b/public/static/js/signup.js index 4031b32..91836f6 100644 --- a/public/static/js/signup.js +++ b/public/static/js/signup.js @@ -14,6 +14,9 @@ if (this.response.error) { var errorText; switch (this.response.error) { + case 'email_not_valid': + errorText = 'The given email address is not valid.' + break; case 'passwords_too_short': errorText = 'The given password is too short. Please choose a password that is at least 6 characters long!' break; diff --git a/src/Controller/SignupController.php b/src/Controller/SignupController.php index ea049bc..b50bfe2 100644 --- a/src/Controller/SignupController.php +++ b/src/Controller/SignupController.php @@ -43,6 +43,11 @@ class SignupController return new JsonContent($data); } + if (filter_var($this->request->post('email'), FILTER_VALIDATE_EMAIL) === false) { + $data = ['error' => 'email_not_valid']; + return new JsonContent($data); + } + $select = new Select(\Container::$dbConnection, 'users'); $select->columns(User::getFields()); $select->where('email', '=', $this->request->post('email'));