implemented brute force counter measure

This commit is contained in:
2025-08-27 19:09:56 +02:00
parent 55340bc929
commit e1f32c274b
8 changed files with 111 additions and 62 deletions

View File

@@ -9,11 +9,16 @@
let credentials = $state({ username : null, password : null });
const router = useTinyRouter();
let services = $state([]);
let error = $state(null);
function doLogin(ev){
async function doLogin(ev){
ev.preventDefault();
tryLogin(credentials);
const json = await tryLogin(credentials);
if (json) {
json.release_time = json.release_time.replace('T',' ');
error = t('failed_login_attempts',json);
}
}
function init(element){
@@ -76,6 +81,9 @@
<form onsubmit={doLogin}>
<fieldset>
{#if error}
<span class="error">{error}</span>
{/if}
<legend>{t('login')}</legend>
<label>
<input type="text" bind:value={credentials.username} required use:init />

View File

@@ -43,8 +43,10 @@ export async function tryLogin(credentials){
if (response.ok){
const json = await response.json();
for (let key of Object.keys(json)) user[key] = json[key];
return null;
} else {
alert("Login failed!");
let json = await response.json();
return json;
}
}