mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
- core/Auth_Controller does NOT load anymore hlp_authentication helper
- Added function getAuthPersonId to hlp_authentication helper - Added function isLogged to hlp_common helper - hlp_authentication helper functions getAuthPersonId and getAuthUID make use of isLogged function - AuthLib loads hlp_authentication helper after a successful login or if a user is already logged - FilterLib does NOT load anymore hlp_authentication helper - FilterLib does NOT use anymore BenutzerModel and getAuthUID, but retrieves user data directly using the person_id from getAuthPersonId
This commit is contained in:
@@ -2,20 +2,35 @@
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// Functions needed to manage the user authentication
|
||||
// ------------------------------------------------------------------------
|
||||
// NOTE: the following functions do NOT prompt a login page if the user is NOT logged in
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* It calls the AuthLib, if the user is NOT logged then the login page is shown
|
||||
* If the user is NOT logged then a null value is returned.
|
||||
* If the user is alredy logged, then it is possible to access to the authentication object
|
||||
* that contains the person_id of the logged user
|
||||
* NOTE: if a user is logged then a person_id is always present!
|
||||
*/
|
||||
function getAuthPersonId()
|
||||
{
|
||||
$ci =& get_instance(); // get CI instance
|
||||
|
||||
return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_PERSON_ID} : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the user is NOT logged then a null value is returned.
|
||||
* If the user is alredy logged, then it is possible to access to the authentication object
|
||||
* that contains the username of the logged user
|
||||
*
|
||||
* @return string or null
|
||||
* NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool),
|
||||
* then it is possible that the username is null!
|
||||
*/
|
||||
function getAuthUID()
|
||||
{
|
||||
$ci =& get_instance(); // get CI instance
|
||||
|
||||
return ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME};
|
||||
return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME} : null;
|
||||
}
|
||||
|
||||
@@ -224,3 +224,19 @@ function isDateWorkingDay($date, $days = null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user is logged by checking that the AuthLib is loaded and
|
||||
* it is present the authentication object in session
|
||||
* NOTE: it is placed here instead of being placed in the helper hlp_authentication_helper
|
||||
* because hlp_authentication_helper is loaded after the authentication.
|
||||
* It is very useful to use this function even in those parts of the code that are accessible
|
||||
* even when a user is NOT authenticated!!!
|
||||
* If and only if this function returns true, then all the functions present in hlp_authentication_helper can be used!
|
||||
*/
|
||||
function isLogged()
|
||||
{
|
||||
$ci =& get_instance(); // get CI instance
|
||||
|
||||
return isset($ci->authlib) && $ci->authlib->getAuthObj() != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user