lithium\security\auth\adapter\Form::__construct()

public method

Constructor. Sets the initial configuration for the Form adapter, as detailed below.

Parameters

  • array $config

    Available configuration options: 'model' string: The name of the model class to use. See the $_model property for details. 'fields' array: The model fields to query against when taking input from the request data. See the $_fields property for details. 'scope' array: Any additional conditions used to constrain the authentication query. For example, if active accounts in an application have an active field which must be set to true, you can specify 'scope' => ['active' => true]. See the $_scope property for more details. 'filters' array: Named callbacks to apply to request data before the user lookup query is generated. See the $_filters property 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 $_validators property for more details. 'query' string: Determines the model method to invoke for authentication checks. See the $_query property for more details.

Returns

void

Source

	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'));

		parent::__construct($config + $defaults);
	}