mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-12-25 04:58:59 +00:00
Transformed user class as components class
This commit is contained in:
parent
db4c939864
commit
97d7825426
@ -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)
|
||||
|
@ -242,4 +242,7 @@ class User{
|
||||
return crypt(sha1($userPassword), sha1($userPassword));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Register class
|
||||
Components::register("user", new User());
|
@ -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']
|
||||
));
|
||||
|
5
init.php
5
init.php
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user