implemented brute force counter measure
This commit is contained in:
@@ -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 />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user