public class Auth
User authentication component. This is the basic authentication component; you can use this class if you only need toallow/disallow access to a page. If you need groups and roles support see the classGroupAuth and the class RoleAuth documentation.
Auth
| Author(s): | Julio César Carrascal Urquijo <jcesar@phreaker.net> |
|---|---|
| Version: | 2.4 pl3 |
| Direct known subclasses: | GroupAuth, RoleAuth |
| array | $user | Holds user information. |
| boolean | $isIdentified | If the user has been identified |
| string | $cacheLevel | Wich cache level to use. |
| string | $dbdriver | Database driver. Example 'mysql', 'mssql', 'oci8'... |
| string | $hostname | Database hostname server. |
| string | $username | Database username |
| string | $password | Database password |
| string | $database | Database. |
| string | $_conn | Holds an ADOConnection instance. |
| array | $_options | This array hold database configuration and execution options. |
| AUTH_INVALID_USER | »-2« |
The username/password pair is invalid. |
| AUTH_EXPIRED | »-3« |
The session has expired. |
| AUTH_ACCESS_DENIED | »-4« |
You don't have access to this area. |
| AUTH_CACHE | »2« |
Allow the browser to cache the page but proxys can't. |
| AUTH_NO_CACHE | »1« |
Do not allow anyone to cache the page. |
| AUTH_NEED_LOGIN | »-1« |
Need a valid username/password pair. |
public void Auth( [ string $options ] );
Constructor.
| Parameters: | ||||||
|
||||||
Returns: void |
||||||
public void startSession( );
Initialize the session. Use this method only if loggin in to the current page is optional but you willwant to have access to the user's information if he has already been identified.
Returns: void |
public void forceLogin( );
Force the user to identify him self.
Returns: void |
public void logout( );
Delete all session information and logout the user.
Returns: void |
public void refreshInfo( );
Updates the user's information from the database. The user must be identified already. Usefull if you just updated the database andyou need to update your session variable.
Returns: void |
private void _callback( int $action, [ string $message ] );
Just calls the callback function and dies.
| Parameters: | ||||||||||||
|
||||||||||||
Returns: void |
||||||||||||
private void _connect( );
Connect to the database only if necesary.
Returns: void |
private array _findByUsername( string $username, string $password );
Search the user in the database by his username and password.
| Parameters: | ||||||||||||
|
||||||||||||
Returns: array users information. |
||||||||||||
| See Also: _findById() | ||||||||||||
private array _findById( int $userId );
Search the user in the database by his user_id field.
| Parameters: | ||||||
|
||||||
Returns: array users information. |
||||||
| See Also: _findByUsername() | ||||||
private bool _checkSession( );
Validates the current session.
Returns: bool |
public array $user
Holds user information.
public boolean $isIdentified
If the user has been identified
public string $cacheLevel
Wich cache level to use.
public string $dbdriver
Database driver. Example 'mysql', 'mssql', 'oci8'...
public string $hostname
Database hostname server.
public string $username
Database username
public string $password
Database password
public string $database
Database.
private string $_conn
Holds an ADOConnection instance.
private array $_options
This array hold database configuration and execution options.
define( AUTH_INVALID_USER, »-2« );
The username/password pair is invalid.
define( AUTH_EXPIRED, »-3« );
The session has expired.
define( AUTH_ACCESS_DENIED, »-4« );
You don't have access to this area.
define( AUTH_CACHE, »2« );
Allow the browser to cache the page but proxys can't.
define( AUTH_NO_CACHE, »1« );
Do not allow anyone to cache the page.
define( AUTH_NEED_LOGIN, »-1« );
Need a valid username/password pair.