Display message when connection is throttled on logi page

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-01-13 21:12:22 +01:00
parent 2997bb9c69
commit 7cab7feb38
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 18 additions and 4 deletions

View file

@ -34,6 +34,7 @@
namespace OC\Core\Controller;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Security\Bruteforce\Throttler;
use OC\User\Session;
use OC_App;
use OC_Util;
@ -72,6 +73,8 @@ class LoginController extends Controller {
private $twoFactorManager;
/** @var Defaults */
private $defaults;
/** @var Throttler */
private $throttler;
/**
* @param string $appName
@ -84,6 +87,7 @@ class LoginController extends Controller {
* @param ILogger $logger
* @param Manager $twoFactorManager
* @param Defaults $defaults
* @param Throttler $throttler
*/
public function __construct($appName,
IRequest $request,
@ -94,7 +98,8 @@ class LoginController extends Controller {
IURLGenerator $urlGenerator,
ILogger $logger,
Manager $twoFactorManager,
Defaults $defaults) {
Defaults $defaults,
Throttler $throttler) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
$this->config = $config;
@ -104,6 +109,7 @@ class LoginController extends Controller {
$this->logger = $logger;
$this->twoFactorManager = $twoFactorManager;
$this->defaults = $defaults;
$this->throttler = $throttler;
}
/**
@ -153,7 +159,7 @@ class LoginController extends Controller {
}
$parameters['messages'] = $messages;
if (!is_null($user) && $user !== '') {
if ($user !== null && $user !== '') {
$parameters['loginName'] = $user;
$parameters['user_autofocus'] = false;
} else {
@ -167,7 +173,7 @@ class LoginController extends Controller {
$parameters['canResetPassword'] = true;
$parameters['resetPasswordLink'] = $this->config->getSystemValue('lost_password_link', '');
if (!$parameters['resetPasswordLink']) {
if (!is_null($user) && $user !== '') {
if ($user !== null && $user !== '') {
$userObj = $this->userManager->get($user);
if ($userObj instanceof IUser) {
$parameters['canResetPassword'] = $userObj->canChangePassword();
@ -181,7 +187,7 @@ class LoginController extends Controller {
$parameters['rememberLoginState'] = !empty($remember_login) ? $remember_login : 0;
$parameters['hideRemeberLoginState'] = !empty($redirect_url) && $this->session->exists('client.flow.state.token');
if (!is_null($user) && $user !== '') {
if ($user !== null && $user !== '') {
$parameters['loginName'] = $user;
$parameters['user_autofocus'] = false;
} else {
@ -189,6 +195,8 @@ class LoginController extends Controller {
$parameters['user_autofocus'] = true;
}
$parameters['throttle_delay'] = $this->throttler->getDelay($this->request->getRemoteAddress());
// OpenGraph Support: http://ogp.me/
Util::addHeader('meta', ['property' => 'og:title', 'content' => Util::sanitizeHTML($this->defaults->getName())]);
Util::addHeader('meta', ['property' => 'og:description', 'content' => Util::sanitizeHTML($this->defaults->getSlogan())]);

View file

@ -62,6 +62,12 @@ script('core', 'merged-login');
</p>
<?php } ?>
<?php if ($_['throttle_delay'] > 5000) { ?>
<p class="warning throttledMsg">
<?php p($l->t('We have detected multiple invalid login attempts from your ip. Because of this we throttle your connection. Login can take up to 30 seconds.')); ?>
</p>
<?php } ?>
<?php if (!empty($_['canResetPassword'])) { ?>
<div id="reset-password-wrapper" style="display: none;">
<input type="submit" id="reset-password-submit" class="login primary" title="" value="<?php p($l->t('Reset password')); ?>" disabled="disabled" />