Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
21 / 21 |
AclUser\Form\ForgottenPasswordForm | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
21 / 21 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
5 / 5 |
|||
addElements | |
100.00% |
1 / 1 |
1 | |
100.00% |
9 / 9 |
|||
addInputFilter | |
100.00% |
1 / 1 |
1 | |
100.00% |
7 / 7 |
<?php | |
/** | |
* Class ResetPasswordForm | |
* | |
* @package AclUser\Form | |
* @author Nigel Hurnell | |
* @version v 1.0.0 | |
* @license BSD | |
* @copyright Copyright (c) 2017, Nigel Hurnell | |
*/ | |
namespace AclUser\Form; | |
use Zend\Form\Form; | |
use Zend\InputFilter\InputFilter; | |
use Zend\Validator\Hostname; | |
/** | |
* This form is used to collect user's E-mail address and the token | |
* that was e-mailed so that the user can define a new password. | |
* | |
* @package AclUser\Form | |
* @author Nigel Hurnell | |
* @version v 1.0.0 | |
* @license BSD | |
* @copyright Copyright (c) 2017, Nigel Hurnell | |
*/ | |
class ForgottenPasswordForm extends Form { | |
/** | |
* Constructor. | |
*/ | |
public function __construct() { | |
// Define form name | |
parent::__construct('reset-password-form'); | |
// Set POST method for this form | |
$this->setAttribute('method', 'post'); | |
$this->addElements(); | |
$this->addInputFilter(); | |
} | |
/** | |
* This method adds elements to form (input fields and submit button). | |
*/ | |
protected function addElements() { | |
// Add "email" field | |
$this->add([ | |
'type' => 'email', | |
'name' => 'email', | |
'options' => [ | |
'label' => 'E-mail', | |
], | |
]); | |
// Add the CAPTCHA field | |
$this->add([ | |
'type' => 'captcha', | |
'name' => 'captcha', | |
'options' => [ | |
'label' => 'Human check', | |
'captcha' => [ | |
'class' => 'Image', | |
'imgDir' => 'public/img/captcha', | |
'suffix' => '.png', | |
'imgUrl' => '/img/captcha/', | |
'imgAlt' => 'CAPTCHA Image', | |
'font' => './data/font/thorne_shaded.ttf', | |
'fsize' => 24, | |
'width' => 350, | |
'height' => 100, | |
'expiration' => 600, | |
'dotNoiseLevel' => 40, | |
'lineNoiseLevel' => 3 | |
], | |
], | |
]); | |
// Add the CSRF field | |
$this->add([ | |
'type' => 'csrf', | |
'name' => 'csrf', | |
'options' => [ | |
'csrf_options' => [ | |
'timeout' => 600 | |
] | |
], | |
]); | |
// Add the Submit button | |
$this->add([ | |
'type' => 'submit', | |
'name' => 'submit', | |
'attributes' => [ | |
'value' => 'Reset Password', | |
'id' => 'submit', | |
], | |
]); | |
} | |
/** | |
* This method creates input filter (used for form filtering/validation). | |
*/ | |
private function addInputFilter() { | |
// Create main input filter | |
$inputFilter = new InputFilter(); | |
$this->setInputFilter($inputFilter); | |
// Add input for "email" field | |
$inputFilter->add([ | |
'name' => 'email', | |
'required' => true, | |
'filters' => [ | |
['name' => 'StringTrim'], | |
], | |
'validators' => [ | |
[ | |
'name' => 'EmailAddress', | |
'options' => [ | |
'allow' => Hostname::ALLOW_DNS, | |
'useMxCheck' => false, | |
], | |
], | |
], | |
]); | |
} | |
} |