lithium\security\auth\adapter\Form::__construct()
Constructor. Sets the initial configuration for the Form adapter, as detailed below.
Parameters
-
array
$configAvailable configuration options:
'model'string: The name of the model class to use. See the$_modelproperty for details.'fields'array: The model fields to query against when taking input from the request data. See the$_fieldsproperty for details.'scope'array: Any additional conditions used to constrain the authentication query. For example, if active accounts in an application have anactivefield which must be set totrue, you can specify'scope' => ['active' => true]. See the$_scopeproperty for more details.'filters'array: Named callbacks to apply to request data before the user lookup query is generated. See the$_filtersproperty for more details.'validators'array: Named callbacks to apply to fields in request data and corresponding fields in database data in order to do programmatic authentication checks after the query has occurred. See the$_validatorsproperty for more details.'query'string: Determines the model method to invoke for authentication checks. See the$_queryproperty for more details.
Returns
voidSource
public function __construct(array $config = []) {
$defaults = [
'model' => 'Users',
'query' => 'first',
'filters' => [],
'validators' => [],
'fields' => ['username', 'password']
];
$config += $defaults;
$password = function($form, $data) {
return Password::check($form, $data);
};
$config['validators'] = array_filter($config['validators'] + compact('password'));
$this->_autoConfig($config + $defaults, $this->_autoConfig);
$this->_autoInit($config);
}