From 400de7e48039c917e2ff9a20a89e9dfde11cde81 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Fri, 4 Mar 2016 20:51:59 -0300 Subject: [PATCH] [Ivan Diaz] - Add signup controller --- api/controllers/user/login.php | 3 +-- api/controllers/user/signup.php | 36 +++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/api/controllers/user/login.php b/api/controllers/user/login.php index f675e84b..39abcaab 100644 --- a/api/controllers/user/login.php +++ b/api/controllers/user/login.php @@ -3,7 +3,6 @@ class LoginController extends Controller { const PATH = '/login'; - public function handler() { $email = Controller::request('email'); $password = Controller::request('password'); @@ -20,4 +19,4 @@ class LoginController extends Controller { } } -$controllerGroup->addController(new LoginController()); +$controllerGroup->addController(new LoginController); diff --git a/api/controllers/user/signup.php b/api/controllers/user/signup.php index 6761d06a..6f1edf6a 100644 --- a/api/controllers/user/signup.php +++ b/api/controllers/user/signup.php @@ -1,18 +1,24 @@ addController('/signup', function () { - $email = Controller::request('email'); - $password = Controller::request('password'); - $userInstance = new User(); - $userInstance->setProperties(array( - 'email' => $email, - 'password' => $password, - 'admin' => 0 - )); - $id = $userInstance->store(); +class SignUpController extends Controller { + const PATH = '/signup'; - Response::respondSuccess(array( - 'id' => $id - )); -}); -*/ \ No newline at end of file + public function handler() { + $email = Controller::request('email'); + $password = Controller::request('password'); + + $userInstance = new User(); + $userInstance->setProperties(array( + 'email' => $email, + 'password' => $password, + 'admin' => 0 + )); + $id = $userInstance->store(); + + Response::respondSuccess(array( + 'id' => $id + )); + } +} + +$controllerGroup->addController(new SignUpController); \ No newline at end of file