
The ACL system has not been completely finished, however all functions listed here are marked as stable.
This class controls user sessions, logins and basic permission control.
void Serenity::user()->set_expiration( $seconds );
Call this before calling check_session() or create_session() to change the session expiration time. The default is 3600 seconds.
Example
// Set expiration to 7200 Serenity::user()->set_expiration( 7200 );
void Serenity::user()->check_session();
This function should always be called in the constructor of your application, before any other user logic. The function checks for a valid session, and if found, populates the member array.
Example
Serenity::user()->check_session(); // Login? if( !Serenity::user()->is_logged_in() ) { print "Not logged in."; }
void Serenity::user()->create_session( &$userDB );
Normally, applications don't have to call this function directly. If you need to create a session, call authenticate() instead on the user login.
bool Serenity::user()->authenticate( $useremail, $password );
Instead of using create_session(), use this function once a member logs in to use their SSO method and create a session.
Example
if( !Serenity::user()->authenticate( $useremail, $password ) ) { // Show login form again } else { // Do some member stuff }
void Serenity::user()->load_user_role();
If using the ACL permission matrix, call this function to load the user's role from the ACL table.
Example
Serenity::user()->load_user_role(); // Are they an admin? if( Serenity::user()->is_admin() ) { print "Im an admin"; }
bool Serenity::user()->is_logged_in();
Helper function to see if the person is logged in.
Example
if( !Serenity::user()->is_logged_in() ) { // Show the login form }
This class provides a dynamic __call() function to access ACL permissions. For instance, to access the is_admin column in the table, you would access:
Serenity::user()->is_admin();
To access any column in the table, just call it as if it were a function.