Transformed user class as components class

This commit is contained in:
Pierre 2017-06-03 14:24:45 +02:00
parent db4c939864
commit 97d7825426
4 changed files with 8 additions and 10 deletions

View File

@ -28,7 +28,7 @@ class userController
$userPassword = $_POST['userPassword'];
//Try to perform login
$loginTokens = CS::get()->user->generateUserLoginTokens($userMail, $userPassword, APIServiceID, $db);
$loginTokens = CS::get()->components->user->generateUserLoginTokens($userMail, $userPassword, APIServiceID, $db);
if(!$loginTokens)
throw new RestException(401, "Invalid e-mail address / password !");
@ -53,7 +53,7 @@ class userController
user_login_required();
//Try to delete token
if(!CS::get()->user->deleteUserLoginToken(userID, APIServiceID))
if(!CS::get()->components->user->deleteUserLoginToken(userID, APIServiceID))
throw new RestException(500, "Something went wrong while trying to logout user !");
//Everything is ok
@ -91,7 +91,7 @@ class userController
Rest_fatal_error(400, "Please specify at least one user ID !");
//Try to get user infos
$userInfos = CS::get()->user->getMultipleUserInfos($usersID);
$userInfos = CS::get()->components->user->getMultipleUserInfos($usersID);
//Check if response is empty
if(count($userInfos) == 0)

View File

@ -242,4 +242,7 @@ class User{
return crypt(sha1($userPassword), sha1($userPassword));
}
}
}
//Register class
Components::register("user", new User());

View File

@ -38,7 +38,7 @@ if(!$cs->tokens->checkClientRequestTokens())
//Check if login tokens where specified
if(isset($_POST['userToken1']) AND isset($_POST['userToken2'])){
//Try to login user
$userID = $cs->user->getUserIDfromToken(APIServiceID, array(
$userID = $cs->components->user->getUserIDfromToken(APIServiceID, array(
$_POST['userToken1'],
$_POST['userToken2']
));

View File

@ -51,11 +51,6 @@ $tokens = new Tokens();
$cs->register("tokens", $tokens);
unset($tokens);
//Add user object
$user = new User();
$cs->register("user", $user);
unset($user);
//Include components
foreach(glob(PROJECT_PATH."classes/components/*.php") as $classFile){
require_once $classFile;