Add reCaptcha to password registration
Summary: See task Test Plan: Attempt to signup with recaptcha disabled. Attempt to signup with recaptcha enabled with incorrect value. Attempt to signup with recaptcha enabled with correct value. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T3832 Differential Revision: https://secure.phabricator.com/D7053
This commit is contained in:
		| @@ -123,6 +123,7 @@ final class PhabricatorAuthRegisterController | |||||||
|     $e_realname = strlen($value_realname) ? null : true; |     $e_realname = strlen($value_realname) ? null : true; | ||||||
|     $e_email = strlen($value_email) ? null : true; |     $e_email = strlen($value_email) ? null : true; | ||||||
|     $e_password = true; |     $e_password = true; | ||||||
|  |     $e_captcha = true; | ||||||
|  |  | ||||||
|     $min_len = PhabricatorEnv::getEnvConfig('account.minimum-password-length'); |     $min_len = PhabricatorEnv::getEnvConfig('account.minimum-password-length'); | ||||||
|     $min_len = (int)$min_len; |     $min_len = (int)$min_len; | ||||||
| @@ -130,6 +131,16 @@ final class PhabricatorAuthRegisterController | |||||||
|     if ($request->isFormPost() || !$can_edit_anything) { |     if ($request->isFormPost() || !$can_edit_anything) { | ||||||
|       $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); |       $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||||
|  |  | ||||||
|  |       if ($must_set_password) { | ||||||
|  |         $e_captcha = pht('Again'); | ||||||
|  |  | ||||||
|  |         $captcha_ok = AphrontFormRecaptchaControl::processCaptcha($request); | ||||||
|  |         if (!$captcha_ok) { | ||||||
|  |           $errors[] = pht("Captcha response is incorrect, try again."); | ||||||
|  |           $e_captcha = pht('Invalid'); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |  | ||||||
|       if ($can_edit_username) { |       if ($can_edit_username) { | ||||||
|         $value_username = $request->getStr('username'); |         $value_username = $request->getStr('username'); | ||||||
|         if (!strlen($value_username)) { |         if (!strlen($value_username)) { | ||||||
| @@ -328,6 +339,13 @@ final class PhabricatorAuthRegisterController | |||||||
|           ->setError($e_realname)); |           ->setError($e_realname)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if ($must_set_password) { | ||||||
|  |       $form->appendChild( | ||||||
|  |         id(new AphrontFormRecaptchaControl()) | ||||||
|  |           ->setLabel('Captcha') | ||||||
|  |           ->setError($e_captcha)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     $submit = id(new AphrontFormSubmitControl()); |     $submit = id(new AphrontFormSubmitControl()); | ||||||
|  |  | ||||||
|     if ($is_setup) { |     if ($is_setup) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Gareth Evans
					Gareth Evans