1 | <?php |
||
19 | class EmailUpdateConfirmation implements EmailUpdateConfirmationInterface |
||
20 | { |
||
21 | const EMAIL_CONFIRMED = 'email_confirmed'; |
||
22 | |||
23 | /** |
||
24 | * @var EmailUpdateConfirmationMailerInterface |
||
25 | */ |
||
26 | private $mailer; |
||
27 | |||
28 | /** |
||
29 | * @var Router |
||
30 | */ |
||
31 | private $router; |
||
32 | |||
33 | /** |
||
34 | * @var TokenGenerator |
||
35 | */ |
||
36 | private $tokenGenerator; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $encryptionMode; |
||
42 | |||
43 | /** |
||
44 | * @var ValidatorInterface |
||
45 | */ |
||
46 | private $validator; |
||
47 | |||
48 | /** |
||
49 | * @var string Route for confirmation link |
||
50 | */ |
||
51 | private $confirmationRoute = 'user_update_email_confirm'; |
||
52 | |||
53 | /** |
||
54 | * @var EventDispatcherInterface |
||
55 | */ |
||
56 | private $eventDispatcher; |
||
57 | |||
58 | /** |
||
59 | * @var string $redirectRoute |
||
60 | */ |
||
61 | private $redirectRoute; |
||
62 | |||
63 | 6 | public function __construct( |
|
84 | |||
85 | /** |
||
86 | * Get $mailer. |
||
87 | * |
||
88 | * @return MailerInterface |
||
89 | */ |
||
90 | public function getMailer() |
||
94 | |||
95 | /** |
||
96 | * Generate new confirmation link for new email based on user confirmation |
||
97 | * token and hashed new user email. |
||
98 | * |
||
99 | * @param Request $request |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function generateConfirmationLink(Request $request, UserInterface $user, $email) |
||
125 | |||
126 | /** |
||
127 | * Fetch email value from hashed part of confirmation link. |
||
128 | * @param UserInterface $user |
||
129 | * @param string $hashedEmail |
||
130 | * |
||
131 | * @return string Encrypted email |
||
132 | */ |
||
133 | 1 | public function fetchEncryptedEmailFromConfirmationLink($user, $hashedEmail) |
|
142 | |||
143 | /** |
||
144 | * Get token which indicates that email was confirmed. |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getEmailConfirmedToken() |
||
152 | |||
153 | /** |
||
154 | * Return IV size. |
||
155 | * |
||
156 | * @return int |
||
157 | */ |
||
158 | 3 | protected function getIvSize() |
|
162 | |||
163 | /** |
||
164 | * Encrypt email value with specified user confirmation token. |
||
165 | * @param string $userConfirmationToken |
||
166 | * @param string $email |
||
167 | * |
||
168 | * @return string Encrypted email |
||
169 | */ |
||
170 | 5 | public function encryptEmailValue($userConfirmationToken, $email) |
|
199 | |||
200 | /** |
||
201 | * Decrypt email value with specified user confirmation token. |
||
202 | * @param string $userConfirmationToken |
||
203 | * @param string $encryptedEmail |
||
204 | * |
||
205 | * @return string Decrypted email |
||
206 | */ |
||
207 | 4 | public function decryptEmailValue($userConfirmationToken, $encryptedEmail) |
|
243 | } |
||
244 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: