[Ivan Diaz] - Code Updates

This commit is contained in:
Ivan Diaz 2015-11-18 21:57:59 -03:00
parent b3df77988b
commit 4873613799
5 changed files with 9 additions and 22 deletions

View File

@ -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";
});
});

View File

@ -1,4 +1,4 @@
<?php
class ERRORS {
const UNDEFINED_CREDENTIALS = 'User or password is not defined';
const INVALID_CREDENTIALS = 'User or password is not defined';
}

View File

@ -8,9 +8,6 @@ class User extends DataStore {
'password',
'admin',
);
const ERRORS = array(
'UNDEFINED_CREDENTIALS' => 'User or password is not defined'
);
public static function getUser($value, $property = 'id') {
if ($property === 'id') {

View File

@ -1,11 +0,0 @@
<?php
class UserTest extends PHPUnit_Framework_TestCase
{
// ...
public function testCanBeNegated()
{
$this->assertEquals(2, 2);
}
}