Initial local commit

This commit is contained in:
2025-09-03 11:07:29 +02:00
commit e6cf08893e
20 changed files with 11387 additions and 0 deletions

371
adminlogin.html Normal file
View File

@@ -0,0 +1,371 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ninja Server - Login</title>
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container {
background: white;
padding: 2rem;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.logo {
text-align: center;
margin-bottom: 2rem;
}
.logo h1 {
color: #333;
font-size: 2rem;
font-weight: 700;
}
.logo p {
color: #666;
margin-top: 0.5rem;
}
.form-container {
display: none;
}
.form-container.active {
display: block;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: #333;
font-weight: 500;
}
.form-group input {
width: 100%;
padding: 0.75rem;
border: 2px solid #e1e5e9;
border-radius: 10px;
font-size: 1rem;
transition: border-color 0.3s ease;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
}
.btn {
width: 100%;
padding: 0.75rem;
border: none;
border-radius: 10px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
margin-bottom: 1rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.btn-secondary {
background: transparent;
color: #667eea;
border: 2px solid #667eea;
}
.btn-secondary:hover {
background: #667eea;
color: white;
}
.toggle-form {
text-align: center;
margin-top: 1rem;
}
.toggle-form button {
background: none;
border: none;
color: #667eea;
cursor: pointer;
text-decoration: underline;
font-size: 0.9rem;
}
.toggle-form button:hover {
color: #764ba2;
}
.message {
padding: 0.75rem;
border-radius: 10px;
margin-bottom: 1rem;
text-align: center;
font-weight: 500;
}
.message.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.message.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.loading {
display: none;
text-align: center;
color: #666;
}
.loading.active {
display: block;
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 0 auto 1rem;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="container">
<div class="logo">
<h1>🥷 Ninja Server</h1>
<p>Secure Authentication Portal</p>
</div>
<div id="message"></div>
<div id="loading" class="loading">
<div class="spinner"></div>
<p>Processing...</p>
</div>
<!-- Login Form -->
<div id="loginForm" class="form-container active">
<h2 style="text-align: center; margin-bottom: 1.5rem; color: #333;">Welcome Back</h2>
<form id="loginFormElement">
<div class="form-group">
<label for="loginEmail">Email</label>
<input type="email" id="loginEmail" required>
</div>
<div class="form-group">
<label for="loginPassword">Password</label>
<input type="password" id="loginPassword" required>
</div>
<button type="submit" class="btn btn-primary">Sign In</button>
</form>
<div class="toggle-form">
<p>Don't have an account? <button type="button" onclick="toggleForm()">Sign Up</button></p>
</div>
</div>
<!-- Register Form -->
<div id="registerForm" class="form-container">
<h2 style="text-align: center; margin-bottom: 1.5rem; color: #333;">Create Account</h2>
<form id="registerFormElement">
<div class="form-group">
<label for="registerEmail">Email</label>
<input type="email" id="registerEmail" required>
</div>
<div class="form-group">
<label for="registerPassword">Password</label>
<input type="password" id="registerPassword" required minlength="6">
</div>
<div class="form-group">
<label for="confirmPassword">Confirm Password</label>
<input type="password" id="confirmPassword" required>
</div>
<button type="submit" class="btn btn-primary">Create Account</button>
</form>
<div class="toggle-form">
<p>Already have an account? <button type="button" onclick="toggleForm()">Sign In</button></p>
</div>
</div>
</div>
<script>
// Supabase configuration
const SUPABASE_URL = 'https://lfxlplnypzvjrhftaoog.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxmeGxwbG55cHp2anJoZnRhb29nIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyMTQ3NzIsImV4cCI6MjA2NDc5MDc3Mn0.XR4preBqWAQ1rT4PFbpkmRdz57BTwIusBI89fIxDHM8';
// Initialize Supabase client
const supabase = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
// Check if user is already logged in
async function checkAuth() {
const { data: { session } } = await supabase.auth.getSession();
if (session) {
window.location.href = 'dashboard.html';
}
}
// Toggle between login and register forms
function toggleForm() {
const loginForm = document.getElementById('loginForm');
const registerForm = document.getElementById('registerForm');
if (loginForm.classList.contains('active')) {
loginForm.classList.remove('active');
registerForm.classList.add('active');
} else {
registerForm.classList.remove('active');
loginForm.classList.add('active');
}
clearMessage();
}
// Show message
function showMessage(message, type = 'success') {
const messageDiv = document.getElementById('message');
messageDiv.innerHTML = `<div class="message ${type}">${message}</div>`;
setTimeout(() => {
messageDiv.innerHTML = '';
}, 5000);
}
// Clear message
function clearMessage() {
document.getElementById('message').innerHTML = '';
}
// Show/hide loading
function setLoading(show) {
const loading = document.getElementById('loading');
if (show) {
loading.classList.add('active');
} else {
loading.classList.remove('active');
}
}
// Handle login
document.getElementById('loginFormElement').addEventListener('submit', async (e) => {
e.preventDefault();
setLoading(true);
clearMessage();
const email = document.getElementById('loginEmail').value;
const password = document.getElementById('loginPassword').value;
try {
const { data, error } = await supabase.auth.signInWithPassword({
email: email,
password: password
});
if (error) {
showMessage(error.message, 'error');
} else {
showMessage('Login successful! Redirecting...', 'success');
setTimeout(() => {
window.location.href = 'dashboard.html';
}, 1000);
}
} catch (error) {
showMessage('An unexpected error occurred', 'error');
} finally {
setLoading(false);
}
});
// Handle registration
document.getElementById('registerFormElement').addEventListener('submit', async (e) => {
e.preventDefault();
setLoading(true);
clearMessage();
const email = document.getElementById('registerEmail').value;
const password = document.getElementById('registerPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (password !== confirmPassword) {
showMessage('Passwords do not match', 'error');
setLoading(false);
return;
}
if (password.length < 6) {
showMessage('Password must be at least 6 characters', 'error');
setLoading(false);
return;
}
try {
const { data, error } = await supabase.auth.signUp({
email: email,
password: password
});
if (error) {
showMessage(error.message, 'error');
} else {
if (data.user && !data.user.email_confirmed_at) {
showMessage('Registration successful! Please check your email to confirm your account.', 'success');
} else {
showMessage('Registration successful! Redirecting...', 'success');
setTimeout(() => {
window.location.href = 'dashboard.html';
}, 1000);
}
}
} catch (error) {
showMessage('An unexpected error occurred', 'error');
} finally {
setLoading(false);
}
});
// Check authentication on page load
checkAuth();
</script>
</body>
</html>