Zeta Components Manual :: Docs For Class ezcAuthenticationDatabaseFilter
AuthenticationDatabaseTiein::ezcAuthenticationDatabaseFilter
Class ezcAuthenticationDatabaseFilter
Filter to authenticate against a database.
The database instance to use is specified using a ezcAuthenticationDatabaseInfo structure. Table name and field names are specified in the same structure.
Example:
- $credentials = new ezcAuthenticationPasswordCredentials( 'jan.modaal', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e' );
- $database = new ezcAuthenticationDatabaseInfo( ezcDbInstance::get(), 'users', array( 'user', 'password' ) );
- {
- // authentication did not succeed, so inform the user
- $status = $authentication->getStatus();
- $err = array(
- 'ezcAuthenticationDatabaseFilter' => array(
- )
- );
- foreach ( $status as $line )
- {
- echo $err[$key][$value] . "\n";
- }
- }
- else
- {
- // authentication succeeded, so allow the user to see his content
- }
Extra data can be fetched from the database during the authentication process, by registering the data to be fetched before calling run(). Example:
- // $filter is an ezcAuthenticationDatabaseFilter object
- // after run()
The $data array will be something like:
- array( 'name' => array( 'John Doe' ),
- 'country' => array( 'US' )
- );
Source for this file: /AuthenticationDatabaseTiein/src/filters/database/database_filter.php
Implements interfaces:
ezcAuthenticationFilter | --ezcAuthenticationDatabaseFilter
Version: | //autogentag// |
Constants
STATUS_PASSWORD_INCORRECT
= 2
|
Password is incorrect. |
STATUS_USERNAME_INCORRECT
= 1
|
Username is not found in the database. |
Inherited Constants
From ezcAuthenticationFilter: | |
---|---|
ezcAuthenticationFilter::STATUS_OK
|
Successful authentication. |
Properties
ezcAuthenticationDatabaseInfo | read/write |
$database
Structure which holds a database instance, table name and fields which are used for authentication. |
Member Variables
protected array(string=>mixed) |
$data
= array()
Holds the extra data fetched during the authentication process. Usually it has this structure:
|
protected array(string) |
$requestedData
= array()
Holds the attributes which will be requested during the authentication process. Usually it has this structure:
|
Inherited Member Variables
From ezcAuthenticationFilter | |
---|---|
protected |
ezcAuthenticationFilter::$options
|
Method Summary
public ezcAuthenticationDatabaseFilter |
__construct(
$database
, [ $options
= null] )
Creates a new object of this class. |
public array(string=>mixed) |
fetchData(
)
Returns the extra data which was fetched during the authentication process. |
public void |
registerFetchData(
[ $data
= array()] )
Registers the extra data which will be fetched by the filter during the authentication process. |
public int |
run(
$credentials
)
Runs the filter and returns a status code when finished. |
Inherited Methods
From ezcAuthenticationFilter | |
---|---|
public ezcAuthenticationFilterOptions |
ezcAuthenticationFilter::getOptions()
Returns the options of this class. |
public abstract int |
ezcAuthenticationFilter::run()
Runs the filter and returns a status code when finished. |
public void |
ezcAuthenticationFilter::setOptions()
Sets the options of this class to $options. |
Methods
__construct
Creates a new object of this class.
Parameters:
Name | Type | Description |
---|---|---|
$database |
ezcAuthenticationDatabaseInfo | Database to use in authentication |
$options |
ezcAuthenticationDatabaseOptions | Options for this class |
fetchData
Returns the extra data which was fetched during the authentication process.
Example of returned array:
- array( 'name' => array( 'John Doe' ),
- 'country' => array( 'US' )
- );
registerFetchData
Registers the extra data which will be fetched by the filter during the authentication process.
The input $data should be an array of attributes, for example:
- array( 'name', 'country' );
Parameters:
Name | Type | Description |
---|---|---|
$data |
array(string) | The extra data to fetch during authentication |
run
Runs the filter and returns a status code when finished.
Parameters:
Name | Type | Description |
---|---|---|
$credentials |
ezcAuthenticationPasswordCredentials | Authentication credentials |
Redefinition of:
Method | Description |
---|---|
ezcAuthenticationFilter::run() |
Runs the filter and returns a status code when finished. |