init
This commit is contained in:
commit
1e11c8ca5e
12 changed files with 579 additions and 0 deletions
62
site/login/index.html
Normal file
62
site/login/index.html
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - nginx auth demo</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</head>
|
||||
<body class="bg-gray-900 text-white min-h-screen flex items-center justify-center">
|
||||
<div class="text-center space-y-6 max-w-md mx-auto">
|
||||
<h1 class="text-4xl font-bold text-blue-400">Login</h1>
|
||||
<p class="text-gray-300">Enter your credentials</p>
|
||||
|
||||
<form id="loginForm" class="space-y-4">
|
||||
<div>
|
||||
<input type="text" id="username" placeholder="Username"
|
||||
class="w-full px-4 py-3 bg-gray-800 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<input type="password" id="password" placeholder="Password"
|
||||
class="w-full px-4 py-3 bg-gray-800 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-blue-500">
|
||||
</div>
|
||||
<button type="submit" class="w-full px-6 py-3 bg-blue-600 hover:bg-blue-700 rounded text-white font-semibold">
|
||||
Login
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="bg-gray-800 rounded p-4 text-sm">
|
||||
<p class="text-gray-300 mb-2">Demo credentials:</p>
|
||||
<p class="text-blue-300">admin / admin (can access /admin)</p>
|
||||
<p class="text-green-300">reader / reader (cannot access /admin)</p>
|
||||
</div>
|
||||
|
||||
<a href="/" class="inline-block px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded">Back to Home</a>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
try {
|
||||
const response = await fetch('/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + btoa(username + ':' + password)
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
window.location.href = '/';
|
||||
} else {
|
||||
alert('Invalid credentials');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Login failed');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue