diff --git a/emhttp/plugins/dynamix/include/.login.php b/emhttp/plugins/dynamix/include/.login.php index 697a1bc24..2cf8af4f5 100644 --- a/emhttp/plugins/dynamix/include/.login.php +++ b/emhttp/plugins/dynamix/include/.login.php @@ -165,10 +165,7 @@ if (!empty($username) && !empty($password)) { // Check if we're limited if ($failCount >= $maxFails) { - if ($failCount == $maxFails) { - my_logger("Ignoring login attempts for {$username} from {$remote_addr}"); - } - throw new Exception(_('Too many invalid login attempts')); + throw new Exception(_('Too many previous login attempts.').'
'.sprintf(_('Logins prevented for %s'),'')); } // Bail if username + password combo doesn't work @@ -193,10 +190,17 @@ if (!empty($username) && !empty($password)) { } catch (Exception $exception) { // Set error message $error = $exception->getMessage(); - - // Log error to syslog - my_logger("Unsuccessful login user {$username} from {$remote_addr}"); appendToFile($failFile, $time . "\n"); + // Log error to syslog + $coolReset = ""; + if ($failCount == ($maxFails - 1)) { + $error .= '
'.sprintf(_('Logins prevented for %s'),''); + } + if ($failCount >= $maxFails) { + $coolReset = "Ignoring login attempts for {$cooldown} seconds."; + } + + my_logger("Unsuccessful login user {$username} from {$remote_addr}. {$coolReset}"); } } @@ -586,9 +590,9 @@ $isDarkTheme = $themeHelper->isDarkTheme();

- -

- + +

+ @@ -611,6 +615,48 @@ $isDarkTheme = $themeHelper->isDarkTheme(); document.body.textContent = ''; document.body.appendChild(errorElement); } + + let timeInSecs; + let ticker; + + function startTimer(secs) { + timeInSecs = parseInt(secs); + ticker = setInterval(tick, 1000); + } + + function tick() { + var secs = timeInSecs; + + updateMessage(prettyTime(secs),"countdown"); + + if (secs > 0) { + timeInSecs--; + } else { + clearInterval(ticker); + // remove the error message after 10 seconds after the timer has expired + updateMessage("","error"); + setTimeout(function() { + updateMessage("","error"); + }, 10000); + return; + } + } + function updateMessage(msg,ID) { + var element = document.getElementById(ID); + if (element) { + element.innerHTML = msg; + } + } + function prettyTime(secs) { + var mins = Math.floor(secs/60); + secs %= 60; + return ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; + } + + if ( document.getElementById("countdown") ) { + startTimer(); + } +