| 1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Form\Auth;
|
|
|
6 |
|
|
|
7 |
use Laminas\Form\Form;
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
class ResetPasswordForm extends Form
|
|
|
11 |
{
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
*
|
|
|
15 |
* @param array $config
|
|
|
16 |
*/
|
|
|
17 |
public function __construct($config)
|
|
|
18 |
{
|
|
|
19 |
|
|
|
20 |
parent::__construct();
|
|
|
21 |
$this->setInputFilter(new ResetPasswordFilter());
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
$this->add([
|
|
|
25 |
'name' => 'password',
|
|
|
26 |
'type' => \Laminas\Form\Element\Password::class,
|
|
|
27 |
'attributes' => [
|
|
|
28 |
'maxlength' => 16,
|
|
|
29 |
'id' => 'password',
|
|
|
30 |
]
|
|
|
31 |
]);
|
|
|
32 |
$this->add([
|
|
|
33 |
'name' => 'confirmation',
|
|
|
34 |
'type' => \Laminas\Form\Element\Password::class,
|
|
|
35 |
'attributes' => [
|
|
|
36 |
'maxlength' => 16,
|
|
|
37 |
'id' => 'confirmation',
|
|
|
38 |
]
|
|
|
39 |
]);
|
|
|
40 |
|
|
|
41 |
if($config['leaderslinked.runmode.sandbox']) {
|
|
|
42 |
$site_key = $config['leaderslinked.google_captcha.sandbox_site_key'];
|
|
|
43 |
$secret_key = $config['leaderslinked.google_captcha.sandbox_secret_key'];
|
|
|
44 |
} else {
|
|
|
45 |
$site_key = $config['leaderslinked.google_captcha.production_site_key'];
|
|
|
46 |
$secret_key = $config['leaderslinked.google_captcha.production_secret_key'];
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
$curl = new \Laminas\Http\Client\Adapter\Curl();
|
|
|
50 |
$curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST,false);
|
|
|
51 |
$curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER,false);
|
|
|
52 |
|
|
|
53 |
$httpClient = new \Laminas\Http\Client();
|
|
|
54 |
$httpClient->setAdapter($curl);
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
$captcha = new \Laminas\Captcha\ReCaptcha();
|
|
|
58 |
$captcha->setService(new \Laminas\ReCaptcha\ReCaptcha($site_key, $secret_key, $params = null, $options = ['callback' => 'enableBtn'], $ip = null, $httpClient));
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
// Add the CAPTCHA field
|
|
|
62 |
$this->add([
|
|
|
63 |
'type' => 'captcha',
|
|
|
64 |
'name' => 'captcha',
|
|
|
65 |
'attributes' => [
|
|
|
66 |
'data-role' => 'none',
|
|
|
67 |
],
|
|
|
68 |
'options' => [
|
|
|
69 |
'captcha' => $captcha,
|
|
|
70 |
],
|
|
|
71 |
]);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
}
|