Initial commit

This commit is contained in:
2025-10-18 10:41:36 +02:00
commit 983c860b26
13 changed files with 939 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="pl" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>PassMetric</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" th:href="@{/css/password.css}">
</head>
<body>
<h1>Sprawdź siłę hasła</h1>
<form>
<label for="password">Hasło</label>
<input type="password" id="password" autocomplete="off">
</form>
<p id="liveMessage" aria-live="polite"></p>
<script>
const input = document.getElementById('password');
const out = document.getElementById('liveMessage');
let t;
input.addEventListener('input', () => {
clearTimeout(t);
const val = input.value;
if (!val) { out.textContent = ''; return; }
t = setTimeout(async () => {
try {
const resp = await fetch('/api/password/strength', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ password: val })
});
if (!resp.ok) { out.textContent = 'Błąd sprawdzania'; return; }
const data = await resp.json();
out.textContent = data.message || '';
out.className = '';
switch (data.message) {
case "Bardzo słabe hasło":
out.classList.add("bad");
break;
case "Słabe hasło":
out.classList.add("warn");
break;
case "Średnie hasło":
out.classList.add("warn");
break;
case "Silne hasło":
out.classList.add("ok");
break;
case "Bardzo silne hasło":
out.classList.add("ok");
break;
}
} catch {
out.textContent = 'Błąd sieci';
}
}, 150);
});
</script>
</body>
</html>