|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the 2amigos/yii2-usuario project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2amigOS! <http://2amigos.us/> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view |
|
9
|
|
|
* the LICENSE file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Da\User\Form; |
|
13
|
|
|
|
|
14
|
|
|
use Da\User\Query\UserQuery; |
|
15
|
|
|
use Da\User\Traits\ContainerAwareTrait; |
|
16
|
|
|
use Yii; |
|
17
|
|
|
use yii\base\Model; |
|
18
|
|
|
|
|
19
|
|
|
class RecoveryForm extends Model |
|
20
|
|
|
{ |
|
21
|
|
|
use ContainerAwareTrait; |
|
22
|
|
|
|
|
23
|
|
|
const SCENARIO_REQUEST = 'request'; |
|
24
|
|
|
const SCENARIO_RESET = 'reset'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string User's email |
|
28
|
|
|
*/ |
|
29
|
|
|
public $email; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var string User's password |
|
32
|
|
|
*/ |
|
33
|
|
|
public $password; |
|
34
|
|
|
/** |
|
35
|
|
|
* @var UserQuery |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $query; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param UserQuery $query |
|
41
|
|
|
* @param array $config |
|
42
|
|
|
*/ |
|
43
|
1 |
|
public function __construct(UserQuery $query, array $config = []) |
|
44
|
|
|
{ |
|
45
|
1 |
|
$this->query = $query; |
|
46
|
1 |
|
parent::__construct($config); |
|
47
|
1 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function attributeLabels() |
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
1 |
|
'email' => Yii::t('usuario', 'Email'), |
|
56
|
1 |
|
'password' => Yii::t('usuario', 'Password'), |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function scenarios() |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
66
|
1 |
|
self::SCENARIO_REQUEST => ['email'], |
|
67
|
1 |
|
self::SCENARIO_RESET => ['password'], |
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritdoc} |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public function rules() |
|
75
|
|
|
{ |
|
76
|
|
|
return [ |
|
77
|
1 |
|
'emailTrim' => ['email', 'filter', 'filter' => 'trim'], |
|
78
|
|
|
'emailRequired' => ['email', 'required'], |
|
79
|
|
|
'emailPattern' => ['email', 'email'], |
|
80
|
|
|
'passwordRequired' => ['password', 'required'], |
|
81
|
|
|
'passwordLength' => ['password', 'string', 'max' => 72, 'min' => 6], |
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|