Called by the Auth class to run an authentication check against a model class using the
credentials in a data container (a Request object), and returns an array of user
information on success, or false on failure.
public check ( object $credentials, array $options = [] ) : array | ||
$credentials | object | A data container which wraps the authentication credentials used to query the model (usually a `Request` object). See the documentation for this class for further details. |
$options | array | Additional configuration options. Not currently implemented in this adapter. |
Результат | array | Returns an array containing user information on success, or `false` on failure. |
/** * Tests that attempted exploitation via malformed credential submission. * * @return void */ public function testLoginWithArray() { $subject = new Form(array('model' => __CLASS__)); $request = new Request(); $request->data = array('username' => array('!=' => ''), 'password' => ''); $result = $subject->check($request); $this->assertEqual('Array', $result['username']); }
public function testLoginWithFilters() { $subject = new Form(array('model' => __CLASS__, 'filters' => array('username' => 'sha1'))); $request = new Request(); $request->data = array('username' => 'Person', 'password' => 'password'); $result = $subject->check($request); $expected = array('username' => sha1('Person'), 'password' => sha1('password')); $this->assertEqual($expected, $result); }
public function testValidatorWithFieldMapping() { $subject = new Form(array('model' => __CLASS__, 'query' => 'validatorFieldMappingTest', 'fields' => array('name' => 'user.name', 'password' => 'user.password'), 'validators' => array('password' => function ($form, $data) { if ($form === $data) { return true; } return false; }))); $request = (object) array('data' => array('name' => 'Foo', 'password' => 'bar')); $this->assertTrue($subject->check($request)); }