The ProPHPScriptUserAuthentication Class
Description
This is really the core of User Session Pro. The class deals with the logging in and out of users and which dialog to show when the login dialog is requested.
Attriubutes
| Attribute Name | Type | Purpose / Notes |
| username | string | The currently logged in users username. |
| user_access_level | int | The access level granted to the currently logged in user. |
| userid | int | The currently logged in users userid. |
| last_login | int | The unix timestamp of the last login action of the current user. |
| additonalFields | array | An associative array of additional user data fields, where the keys are the names of the fields in the user table. |
| modules | array | An associative array of references to active User Session Pro modules. |
| error_message | string | The current error message html |
| path_to_templates | string | The file path to be used to find default templates. |
| user_table | string | The name of the mySQL table used as the user table. |
| logout_post_var | string | The name of the $_POST variable used to indicate the user wishes to logout. |
| password_post_var | string | The name of the $_POST variable used to store the currently logging in users password. |
| username_post_var | string | The name of the $_POST variable used to store the currently logging in users username. |
| isLoggedIn | bool | Flags login status, set by calling checkLogin |
Methods
Checks the relevant post and session variables to see if a user is logged in.
To save repeated calls to your database this function actually only runs once if it returns true. Subsequent calls to it will return true without any checking until logout is called.
This function features 3 hooks to allow augmentation of the return result and methods actions:
- onCheckLogin: bool &$this->isLoggedIn, array &$userinfo
- onLoginFailure
- onLoginSuccess
The final return value is $this->isLoggedIn, set this in your hook code to augment behaviour.
Uses checkLogin to show the correct dialog from your login box templates which are editable in the admin panel.
This function will output the required dialog to the screen. To catch the contents of the dialog in a variable use the following snippet:
This method will halt execution of your script and output the default "restricted access" page if the current user is not a registered user and has logged in. The template for the restricted access page can be edited in the control panel.
This method is similar to protectPageMembersOnly, but will exit and show the "restricted access" html if the current users access_level is not greater than or equal to $access_level
This method is similar to protectPageMembersOnly, but will exit and show the "restricted access" html if the current users username is not $username
This method will return true if the current users access level is greater than or equal to $access_level
This method is similar to protectPageMembersOnly, but will exit and show the "restricted access" html if the current user does not belong to $group_name
If you do not have the Extended User Groups module installed the current user is assumed not to have access to any groups.
This method will return true if the current user belongs to $group_name"
If you do not have the Extended User Groups module installed this method will always return false
Similar to showLoginDialog, but shows the correct stage of user registration.
If you do not have the User Registration module installed this method will always return false