mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 07:12:41 +01:00
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:
parent
e8205a2d1e
commit
e1892e9bfb
1 changed files with 18 additions and 0 deletions
|
@ -123,6 +123,7 @@ final class PhabricatorAuthRegisterController
|
|||
$e_realname = strlen($value_realname) ? null : true;
|
||||
$e_email = strlen($value_email) ? null : true;
|
||||
$e_password = true;
|
||||
$e_captcha = true;
|
||||
|
||||
$min_len = PhabricatorEnv::getEnvConfig('account.minimum-password-length');
|
||||
$min_len = (int)$min_len;
|
||||
|
@ -130,6 +131,16 @@ final class PhabricatorAuthRegisterController
|
|||
if ($request->isFormPost() || !$can_edit_anything) {
|
||||
$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) {
|
||||
$value_username = $request->getStr('username');
|
||||
if (!strlen($value_username)) {
|
||||
|
@ -328,6 +339,13 @@ final class PhabricatorAuthRegisterController
|
|||
->setError($e_realname));
|
||||
}
|
||||
|
||||
if ($must_set_password) {
|
||||
$form->appendChild(
|
||||
id(new AphrontFormRecaptchaControl())
|
||||
->setLabel('Captcha')
|
||||
->setError($e_captcha));
|
||||
}
|
||||
|
||||
$submit = id(new AphrontFormSubmitControl());
|
||||
|
||||
if ($is_setup) {
|
||||
|
|
Loading…
Reference in a new issue