From 50c7e3972ca7b7f08fcf12aaf6a2ac8227304b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Thu, 18 Jun 2020 16:12:40 +0200 Subject: [PATCH] MAPG-151 check email address validity on server side --- public/static/js/signup.js | 3 +++ src/Controller/SignupController.php | 5 +++++ 2 files changed, 8 insertions(+) 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'));