Page MenuHomePhabricator

D20667.diff
No OneTemporary

D20667.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2429,6 +2429,7 @@
'PhabricatorAuthTemporaryTokenTypeModule' => 'applications/auth/tokentype/PhabricatorAuthTemporaryTokenTypeModule.php',
'PhabricatorAuthTerminateSessionController' => 'applications/auth/controller/PhabricatorAuthTerminateSessionController.php',
'PhabricatorAuthTestSMSAction' => 'applications/auth/action/PhabricatorAuthTestSMSAction.php',
+ 'PhabricatorAuthTryEmailLoginAction' => 'applications/auth/action/PhabricatorAuthTryEmailLoginAction.php',
'PhabricatorAuthTryFactorAction' => 'applications/auth/action/PhabricatorAuthTryFactorAction.php',
'PhabricatorAuthUnlinkController' => 'applications/auth/controller/PhabricatorAuthUnlinkController.php',
'PhabricatorAuthValidateController' => 'applications/auth/controller/PhabricatorAuthValidateController.php',
@@ -8424,6 +8425,7 @@
'PhabricatorAuthTemporaryTokenTypeModule' => 'PhabricatorConfigModule',
'PhabricatorAuthTerminateSessionController' => 'PhabricatorAuthController',
'PhabricatorAuthTestSMSAction' => 'PhabricatorSystemAction',
+ 'PhabricatorAuthTryEmailLoginAction' => 'PhabricatorSystemAction',
'PhabricatorAuthTryFactorAction' => 'PhabricatorSystemAction',
'PhabricatorAuthUnlinkController' => 'PhabricatorAuthController',
'PhabricatorAuthValidateController' => 'PhabricatorAuthController',
diff --git a/src/applications/auth/action/PhabricatorAuthTryEmailLoginAction.php b/src/applications/auth/action/PhabricatorAuthTryEmailLoginAction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/action/PhabricatorAuthTryEmailLoginAction.php
@@ -0,0 +1,22 @@
+<?php
+
+final class PhabricatorAuthTryEmailLoginAction
+ extends PhabricatorSystemAction {
+
+ const TYPECONST = 'mail.try-login';
+
+ public function getActionConstant() {
+ return self::TYPECONST;
+ }
+
+ public function getScoreThreshold() {
+ return 20 / phutil_units('1 hour in seconds');
+ }
+
+ public function getLimitExplanation() {
+ return pht(
+ 'You have made too many account recovery requests in a short period '.
+ 'of time.');
+ }
+
+}
diff --git a/src/applications/auth/controller/PhabricatorEmailLoginController.php b/src/applications/auth/controller/PhabricatorEmailLoginController.php
--- a/src/applications/auth/controller/PhabricatorEmailLoginController.php
+++ b/src/applications/auth/controller/PhabricatorEmailLoginController.php
@@ -53,6 +53,14 @@
// it expensive to fish for valid email addresses while giving the user
// a better error if they goof their email.
+ $action_actor = PhabricatorSystemActionEngine::newActorFromRequest(
+ $request);
+
+ PhabricatorSystemActionEngine::willTakeAction(
+ array($action_actor),
+ new PhabricatorAuthTryEmailLoginAction(),
+ 1);
+
$target_email = id(new PhabricatorUserEmail())->loadOneWhere(
'address = %s',
$v_email);
diff --git a/src/applications/system/engine/PhabricatorSystemActionEngine.php b/src/applications/system/engine/PhabricatorSystemActionEngine.php
--- a/src/applications/system/engine/PhabricatorSystemActionEngine.php
+++ b/src/applications/system/engine/PhabricatorSystemActionEngine.php
@@ -198,4 +198,8 @@
return $conn_w->getAffectedRows();
}
+ public static function newActorFromRequest(AphrontRequest $request) {
+ return $request->getRemoteAddress();
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 5, 8:06 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7224097
Default Alt Text
D20667.diff (3 KB)

Event Timeline