diff --git a/server/controllers/user.php b/server/controllers/user.php index 9508d582..3125632e 100644 --- a/server/controllers/user.php +++ b/server/controllers/user.php @@ -5,6 +5,7 @@ $app->group('/user', function () use ($app) { echo "Returns the user with $by = $value as a json"; }); + //TODO: THIS METHOD CAN BE ONLY USED IF IT IS LOGIN AS ADMIN $app->get('/add/:user/:pass', function ($user, $pass) use ($app) { $userInstance = new User(); $userInstance->setProperties(array( @@ -21,20 +22,20 @@ $app->group('/user', function () use ($app) { $app->post('/login', function () use ($app) { $user = $app->request()->post('email'); $password = $app->request()->post('password'); - $pass = ''; + if ($userInstance = User::getUser($user, 'user')) { $pass = $userInstance->password; } + else { + return; + Response::respondError(ERRORS::INVALID_CREDENTIALS); + } if ($pass === $password) { Response::respondSuccess(); } else { - Response::respondError(ERRORS::UNDEFINED_CREDENTIALS); + Response::respondError(ERRORS::INVALID_CREDENTIALS); } }); - - $app->post('/add', function () use ($app) { - echo "You have the new"; - }); }); diff --git a/server/models/ERRORS.php b/server/models/ERRORS.php index 898aada5..177ef3b8 100644 --- a/server/models/ERRORS.php +++ b/server/models/ERRORS.php @@ -1,4 +1,4 @@ 'User or password is not defined' - ); public static function getUser($value, $property = 'id') { if ($property === 'id') { diff --git a/server/tests/UserTest.php b/server/tests/UserTest.php deleted file mode 100644 index 2ed71ae6..00000000 --- a/server/tests/UserTest.php +++ /dev/null @@ -1,11 +0,0 @@ -assertEquals(2, 2); - } -}