[Ivan Diaz] - Code Updates
This commit is contained in:
parent
b3df77988b
commit
4873613799
|
@ -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";
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
class Response{
|
||||
class Response {
|
||||
private static $errored;
|
||||
|
||||
public static function respondError($errorMsg, $data = null) {
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
class UserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
// ...
|
||||
|
||||
public function testCanBeNegated()
|
||||
{
|
||||
$this->assertEquals(2, 2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue