mirror of
https://github.com/unraid/webgui.git
synced 2026-01-07 01:59:52 -06:00
Update .login.php
This commit is contained in:
@@ -166,9 +166,9 @@ 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}");
|
||||
my_logger("Ignoring login attempts from {$remote_addr} for {$cooldown} seconds.");
|
||||
}
|
||||
throw new Exception(_('Too many invalid login attempts'));
|
||||
throw new Exception(_('Too many previous login attempts.').'<br>'.sprintf(_('Logins prevented for %s'),'<span id="countdown"></span>'));
|
||||
}
|
||||
|
||||
// Bail if username + password combo doesn't work
|
||||
@@ -193,10 +193,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");
|
||||
$failCount = cleanupFails($failFile, $time);
|
||||
// Log error to syslog
|
||||
$coolReset = "";
|
||||
if ($failCount >= $maxFails) {
|
||||
$coolReset = "Ignoring login attempts for {$cooldown} seconds.";
|
||||
}
|
||||
if ( $failCount == $maxFails ) {
|
||||
$error .= '<br>'.sprintf(_('Logins prevented for %s'),'<span id="countdown"></span>');
|
||||
}
|
||||
my_logger("Unsuccessful login user {$username} from {$remote_addr}. {$coolReset}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,9 +593,9 @@ $isDarkTheme = $themeHelper->isDarkTheme();
|
||||
<p>
|
||||
<button type="submit" class="button button--small"><?= _('Login') ?></button>
|
||||
</p>
|
||||
<?php if ($error) { ?>
|
||||
<p class="error"><?= $error ?></p>
|
||||
<?php } ?>
|
||||
<? if ($error): ?>
|
||||
<p class="error" id="error"><?= $error ?></p>
|
||||
<? endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -610,6 +617,48 @@ $isDarkTheme = $themeHelper->isDarkTheme();
|
||||
document.body.textContent = '';
|
||||
document.body.appendChild(errorElement);
|
||||
}
|
||||
|
||||
var timeInSecs;
|
||||
var 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("<?=_("Wait for this message to disappear")?>","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 ($error):?>
|
||||
if ( document.getElementById("countdown") ) {
|
||||
startTimer(<?=$cooldown?>);
|
||||
}
|
||||
<? endif; ?>
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user