| @@ 150-169 (lines=20) @@ | ||
| 147 | * ) |
|
| 148 | * @throws Exception |
|
| 149 | */ |
|
| 150 | public function resendActivationAction() |
|
| 151 | { |
|
| 152 | if (!$this->httpMethodCheck('GET')) { return; } |
|
| 153 | ||
| 154 | $email = $this->getParam('email'); |
|
| 155 | ||
| 156 | $user = $this->userService->findUserByEmail($email); |
|
| 157 | if (!$user) { |
|
| 158 | $this->sendJsonResponse(['error' => UserException::USER_NOT_FOUND], 404); |
|
| 159 | return; |
|
| 160 | } |
|
| 161 | ||
| 162 | if ($user->getState()->getValue() == State::STATE_ACTIVATED) { |
|
| 163 | $this->sendJsonResponse(['error' => UserException::USER_ACTIVATED], 400); |
|
| 164 | return; |
|
| 165 | } |
|
| 166 | ||
| 167 | $link = $this->userService->generateEmailLink($user); |
|
| 168 | $this->sendJsonObjectResponse($link); |
|
| 169 | } |
|
| 170 | ||
| 171 | /** |
|
| 172 | * Get a lost password email link token. |
|
| @@ 189-208 (lines=20) @@ | ||
| 186 | * ) |
|
| 187 | * @throws Exception |
|
| 188 | */ |
|
| 189 | public function lostPasswordAction() |
|
| 190 | { |
|
| 191 | if (!$this->httpMethodCheck('GET')) { return; } |
|
| 192 | ||
| 193 | $email = $this->getParam('email'); |
|
| 194 | ||
| 195 | $user = $this->userService->findUserByEmail($email); |
|
| 196 | if (!$user) { |
|
| 197 | $this->sendJsonResponse(['error' => UserException::USER_NOT_FOUND], 404); |
|
| 198 | return; |
|
| 199 | } |
|
| 200 | ||
| 201 | if ($user->getState()->getValue() == State::STATE_UNACTIVATED) { |
|
| 202 | $this->sendJsonResponse(['error' => UserException::USER_UNACTIVATED], 400); |
|
| 203 | return; |
|
| 204 | } |
|
| 205 | ||
| 206 | $link = $this->userService->generateEmailLink($user); |
|
| 207 | $this->sendJsonObjectResponse($link); |
|
| 208 | } |
|
| 209 | ||
| 210 | /** |
|
| 211 | * Register as a new user. Returns an email link token. |
|