commit
4f726f524d
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
include 'user/login.php';
|
include 'user/login.php';
|
||||||
include 'user/signup.php';
|
include 'user/signup.php';
|
||||||
|
include 'user/logout.php';
|
||||||
|
|
||||||
$userControllers = new ControllerGroup();
|
$userControllers = new ControllerGroup();
|
||||||
$userControllers->setGroupPath('/user');
|
$userControllers->setGroupPath('/user');
|
||||||
|
|
||||||
$userControllers->addController(new LoginController);
|
$userControllers->addController(new LoginController);
|
||||||
$userControllers->addController(new SignUpController);
|
$userControllers->addController(new SignUpController);
|
||||||
|
$userControllers->addController(new LogoutController);
|
||||||
|
|
||||||
$userControllers->finalize();
|
$userControllers->finalize();
|
||||||
|
|
|
@ -39,7 +39,6 @@ class LoginController extends Controller {
|
||||||
return array(
|
return array(
|
||||||
'userId' => $userInstance->id,
|
'userId' => $userInstance->id,
|
||||||
'userEmail' => $userInstance->email,
|
'userEmail' => $userInstance->email,
|
||||||
'userIsAdmin' => $userInstance->admin,
|
|
||||||
'token' => $this->getSession()->getToken()
|
'token' => $this->getSession()->getToken()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
class LogoutController extends Controller {
|
||||||
|
const PATH = '/logout';
|
||||||
|
|
||||||
|
public function handler() {
|
||||||
|
$session = Session::getInstance();
|
||||||
|
$session->closeSession();
|
||||||
|
|
||||||
|
Response::respondSuccess();
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,8 +19,7 @@ class SignUpController extends Controller {
|
||||||
$userInstance = new User();
|
$userInstance = new User();
|
||||||
$userInstance->setProperties(array(
|
$userInstance->setProperties(array(
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'password' => User::hashPassword($password),
|
'password' => User::hashPassword($password)
|
||||||
'admin' => 0
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return $userInstance->store();
|
return $userInstance->store();
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initSession() {
|
public function initSession() {
|
||||||
|
session_cache_limiter(false);
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@ class User extends DataStore {
|
||||||
public static function getProps() {
|
public static function getProps() {
|
||||||
return array(
|
return array(
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password'
|
||||||
'admin',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultProperties() {
|
public function getDefaultProperties() {
|
||||||
return [
|
return array();
|
||||||
'admin' => 0
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUser($value, $property = 'id') {
|
public static function getUser($value, $property = 'id') {
|
||||||
|
|
|
@ -14,7 +14,6 @@ class User extends \Mock {
|
||||||
$mockUserInstance->id = 'MOCK_ID';
|
$mockUserInstance->id = 'MOCK_ID';
|
||||||
$mockUserInstance->email = 'MOCK_EMAIL';
|
$mockUserInstance->email = 'MOCK_EMAIL';
|
||||||
$mockUserInstance->password = 'MOCK_PASSWORD';
|
$mockUserInstance->password = 'MOCK_PASSWORD';
|
||||||
$mockUserInstance->admin = 'MOCK_ADMIN_VALUE';
|
|
||||||
|
|
||||||
return $mockUserInstance;
|
return $mockUserInstance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ class LoginControllerTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertTrue(Response::get('respondSuccess')->hasBeenCalledWithArgs(array(
|
$this->assertTrue(Response::get('respondSuccess')->hasBeenCalledWithArgs(array(
|
||||||
'userId' => 'MOCK_ID',
|
'userId' => 'MOCK_ID',
|
||||||
'userEmail' => 'MOCK_EMAIL',
|
'userEmail' => 'MOCK_EMAIL',
|
||||||
'userIsAdmin' => 'MOCK_ADMIN_VALUE',
|
|
||||||
'token' => 'TEST_TOKEN'
|
'token' => 'TEST_TOKEN'
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue