1 | <?php |
||
19 | class PasswordReset |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Holds the user Data instance. |
||
24 | */ |
||
25 | protected $userData; |
||
26 | |||
27 | /** |
||
28 | * Holds the password reset Data instance. |
||
29 | */ |
||
30 | protected $passwordResetData; |
||
31 | |||
32 | /** |
||
33 | * Gets the password reset of a token but only if it is younger than 48h. |
||
34 | * |
||
35 | * @param string $token |
||
36 | * the password reset token |
||
37 | * |
||
38 | * @return null|CRUDlex\Entity |
||
39 | * the password reset request |
||
40 | */ |
||
41 | protected function getValidPasswordReset($token) |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param CRUDlex\Data $userData |
||
61 | * the user data instance |
||
62 | * @param CRUDlex\Data $passwordResetData |
||
63 | * the password reset data instance |
||
64 | */ |
||
65 | public function __construct($userData, $passwordResetData) |
||
70 | |||
71 | /** |
||
72 | * Creates a password reset request. |
||
73 | * |
||
74 | * @param string $identifyingField |
||
75 | * the identifying field to grab an user, likely the email |
||
76 | * @param string $identifyingValue |
||
77 | * the identifying value to grab an user, likely the email |
||
78 | * |
||
79 | * @return null|string |
||
80 | * the token of the password reset instance ready to be send to the user via |
||
81 | * a secondary channel like email; might be null if the user could not be |
||
82 | * identified uniquly via the given parameters: either zero or more than one |
||
83 | * users were found |
||
84 | */ |
||
85 | public function requestPasswordReset($identifyingField, $identifyingValue) |
||
108 | |||
109 | /** |
||
110 | * Resets the password of an user belonging to the given password reset |
||
111 | * token. |
||
112 | * |
||
113 | * @param string $token |
||
114 | * the password reset token |
||
115 | * @param string $newPassword |
||
116 | * the new password |
||
117 | * |
||
118 | * @return boolean |
||
119 | * true on success, false on failure with one of this reasons: |
||
120 | * - no or more than one password reset request found for this token |
||
121 | * - the password request for this token is older than 48h |
||
122 | * - the password request for this token has already been used |
||
123 | */ |
||
124 | public function resetPassword($token, $newPassword) |
||
141 | |||
142 | } |
||
143 |