mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-18 16:18:04 +00:00
Can check if a user is allowed to access other user informations
This commit is contained in:
@ -11,15 +11,31 @@
|
||||
*
|
||||
* @return Boolean True for a success
|
||||
*/
|
||||
function user_login_required(){
|
||||
if(!defined("userID")){
|
||||
function user_login_required() : bool{
|
||||
if(!user_signed_in()){
|
||||
Rest_fatal_error(401, "This function requires user to be logged in!");
|
||||
}
|
||||
|
||||
//Check if userID is the number 0
|
||||
if(userID == 0)
|
||||
Rest_fatal_error(401, "This function requires user to be logged in!");
|
||||
|
||||
//User logged in
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check wether the user is signed in or not
|
||||
*
|
||||
* @return TRUE if user is signed in / FALSE else
|
||||
*/
|
||||
function user_signed_in() : bool {
|
||||
|
||||
//Check constant
|
||||
if(!defined("userID"))
|
||||
return false;
|
||||
|
||||
//Check user ID
|
||||
if(userID == 0)
|
||||
return false;
|
||||
|
||||
//User seems to be signed in
|
||||
return true;
|
||||
|
||||
}
|
Reference in New Issue
Block a user