diff --git a/server/controllers/user.php b/server/controllers/user.php index 5aa9cfeb..7ad1054c 100644 --- a/server/controllers/user.php +++ b/server/controllers/user.php @@ -1,11 +1,13 @@ setGroupPath('/user'); $userControllers->addController(new LoginController); $userControllers->addController(new SignUpController); +$userControllers->addController(new LogoutController); $userControllers->finalize(); diff --git a/server/controllers/user/login.php b/server/controllers/user/login.php index 2e499f65..396f5acf 100644 --- a/server/controllers/user/login.php +++ b/server/controllers/user/login.php @@ -39,7 +39,6 @@ class LoginController extends Controller { return array( 'userId' => $userInstance->id, 'userEmail' => $userInstance->email, - 'userIsAdmin' => $userInstance->admin, 'token' => $this->getSession()->getToken() ); } diff --git a/server/controllers/user/logout.php b/server/controllers/user/logout.php new file mode 100644 index 00000000..cab4cccd --- /dev/null +++ b/server/controllers/user/logout.php @@ -0,0 +1,11 @@ +closeSession(); + + Response::respondSuccess(); + } +} \ No newline at end of file diff --git a/server/controllers/user/signup.php b/server/controllers/user/signup.php index 97ff12cc..2a143e3b 100644 --- a/server/controllers/user/signup.php +++ b/server/controllers/user/signup.php @@ -19,8 +19,7 @@ class SignUpController extends Controller { $userInstance = new User(); $userInstance->setProperties(array( 'email' => $email, - 'password' => User::hashPassword($password), - 'admin' => 0 + 'password' => User::hashPassword($password) )); return $userInstance->store(); diff --git a/server/models/Session.php b/server/models/Session.php index d2d6763f..3ca9dedd 100644 --- a/server/models/Session.php +++ b/server/models/Session.php @@ -8,6 +8,7 @@ class Session { } public function initSession() { + session_cache_limiter(false); session_start(); } diff --git a/server/models/User.php b/server/models/User.php index c876130e..669e9835 100644 --- a/server/models/User.php +++ b/server/models/User.php @@ -20,15 +20,12 @@ class User extends DataStore { public static function getProps() { return array( 'email', - 'password', - 'admin', + 'password' ); } public function getDefaultProperties() { - return [ - 'admin' => 0 - ]; + return array(); } public static function getUser($value, $property = 'id') { diff --git a/server/tests/__mocks__/UserMock.php b/server/tests/__mocks__/UserMock.php index b4447c85..112f7c6e 100644 --- a/server/tests/__mocks__/UserMock.php +++ b/server/tests/__mocks__/UserMock.php @@ -14,7 +14,6 @@ class User extends \Mock { $mockUserInstance->id = 'MOCK_ID'; $mockUserInstance->email = 'MOCK_EMAIL'; $mockUserInstance->password = 'MOCK_PASSWORD'; - $mockUserInstance->admin = 'MOCK_ADMIN_VALUE'; return $mockUserInstance; } diff --git a/server/tests/controllers/user/loginTest.php b/server/tests/controllers/user/loginTest.php index 46f56f60..018efd72 100644 --- a/server/tests/controllers/user/loginTest.php +++ b/server/tests/controllers/user/loginTest.php @@ -38,7 +38,6 @@ class LoginControllerTest extends PHPUnit_Framework_TestCase { $this->assertTrue(Response::get('respondSuccess')->hasBeenCalledWithArgs(array( 'userId' => 'MOCK_ID', 'userEmail' => 'MOCK_EMAIL', - 'userIsAdmin' => 'MOCK_ADMIN_VALUE', 'token' => 'TEST_TOKEN' ))); }