Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions features/LimitRetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
use APP\plugins\generic\betterPassword\handlers\DisabledLoginHandler;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\plugins\Hook;
use PKP\security\Validation;
use Carbon\CarbonInterval;

class LimitRetry
{
Expand Down Expand Up @@ -83,15 +85,24 @@ private function _handleTemplateDisplay(): void
// And the user is not currently locked
if ($user->getCount() < $this->_maxRetries || $user->getFailedTime() <= time() - $this->_lockSeconds) {
$badpwFailedLoginsDao->resetCount($user);
// Update the local counter
$count = 0;
}
}

// Update the count to represent this failed attempt
$badpwFailedLoginsDao->incCount($user);
// Update the local counter
$count ++;

// Warn the user if the attempts have been exhausted
if ($count >= $this->_maxRetries) {
$label = CarbonInterval::seconds(max($this->_lockExpiresSeconds, $this->_lockSeconds))
->cascade()
->locale(Locale::getLocale())
->forHumans(['parts' => 2, 'short' => false]);
$templateManager->assign('error', 'plugins.generic.betterPassword.validation.betterPasswordLocked');
$templateManager->assign('reason', $label);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion locale/en/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ msgid "plugins.generic.betterPassword.validation.betterPasswordCheckBlocklist"
msgstr "Your password was found in a blocklist of known bad passwords."

msgid "plugins.generic.betterPassword.validation.betterPasswordLocked"
msgstr "Your account has been temporarily locked due to bad password attempts."
msgstr "Your account has been temporarily locked due to bad password attempts. It will unlock automatically within {$reason}. For immediate access, use the \"Forgot your password?\" link to reset your password."

msgid "plugins.generic.betterPassword.validation.betterPasswordUnexpectedError"
msgstr "Your password could not be changed at this time. Please try again later."
Expand Down