Files
Ninjaserver/public/login.html
2025-09-03 13:34:10 +02:00

567 lines
18 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ninja Server - Admin Login</title>
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', sans-serif;
background: #0a0a0f;
color: #ffffff;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-image:
radial-gradient(circle at 20% 80%, #1a1a2e 0%, transparent 50%),
radial-gradient(circle at 80% 20%, #16213e 0%, transparent 50%),
radial-gradient(circle at 40% 40%, #0f3460 0%, transparent 50%);
position: relative;
}
.back-button {
position: fixed;
top: 20px;
right: 20px;
background: rgba(30, 41, 59, 0.95);
backdrop-filter: blur(20px);
border: 1px solid rgba(51, 65, 85, 0.3);
border-radius: 12px;
padding: 12px 20px;
color: #00d4ff;
text-decoration: none;
font-weight: 600;
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 0.5px;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
z-index: 1000;
}
.back-button:hover {
background: #00d4ff;
color: #ffffff;
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}
.back-button::before {
content: "← ";
margin-right: 5px;
}
.container {
background: rgba(30, 41, 59, 0.95);
backdrop-filter: blur(20px);
border: 1px solid rgba(51, 65, 85, 0.3);
padding: 2.5rem;
border-radius: 1.5rem;
box-shadow:
0 25px 50px rgba(0, 0, 0, 0.3),
0 0 0 1px rgba(0, 212, 255, 0.1);
width: 100%;
max-width: 420px;
}
.logo {
text-align: center;
margin-bottom: 2rem;
}
.logo h1 {
font-size: 2.5rem;
font-weight: 700;
background: linear-gradient(135deg, #00d4ff, #ff6b35, #ffd700);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 0.5rem;
letter-spacing: -0.02em;
}
.logo p {
color: #94a3b8;
margin-top: 0.5rem;
font-size: 1rem;
font-weight: 400;
}
.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: #e2e8f0;
font-weight: 500;
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.form-group input {
width: 100%;
padding: 1rem;
background: #1e293b;
border: 2px solid #334155;
border-radius: 0.75rem;
color: #ffffff;
font-size: 1rem;
font-family: inherit;
transition: all 0.2s ease;
}
.form-group input:focus {
outline: none;
border-color: #00d4ff;
box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}
.form-group input::placeholder {
color: #64748b;
}
.btn {
width: 100%;
padding: 1rem;
border: none;
border-radius: 0.75rem;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
margin-bottom: 1rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.btn-primary {
background: linear-gradient(135deg, #00d4ff, #0891b2);
color: white;
box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4);
}
.btn-secondary {
background: transparent;
color: #00d4ff;
border: 2px solid #00d4ff;
}
.btn-secondary:hover {
background: #00d4ff;
color: #0a0a0f;
}
.toggle-form {
text-align: center;
margin-top: 1rem;
}
.toggle-form button {
background: none;
border: none;
color: #00d4ff;
cursor: pointer;
text-decoration: underline;
font-size: 0.9rem;
transition: color 0.2s ease;
}
.toggle-form button:hover {
color: #0891b2;
}
.message {
padding: 1rem;
border-radius: 0.75rem;
margin-bottom: 1rem;
text-align: center;
font-weight: 500;
border: 1px solid;
}
.message.success {
background: rgba(34, 197, 94, 0.1);
color: #22c55e;
border-color: rgba(34, 197, 94, 0.3);
}
.message.error {
background: rgba(239, 68, 68, 0.1);
color: #ef4444;
border-color: rgba(239, 68, 68, 0.3);
}
.password-reset-container {
display: none;
margin-top: 1rem;
padding: 1rem;
background: rgba(239, 68, 68, 0.05);
border: 1px solid rgba(239, 68, 68, 0.2);
border-radius: 0.75rem;
text-align: center;
}
.password-reset-container.active {
display: block;
}
.password-reset-container p {
color: #ef4444;
margin-bottom: 1rem;
font-size: 0.9rem;
}
.btn-reset {
background: linear-gradient(135deg, #ef4444, #dc2626);
color: white;
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-reset:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}
.loading {
display: none;
text-align: center;
color: #94a3b8;
}
.loading.active {
display: block;
}
.spinner {
border: 3px solid #334155;
border-top: 3px solid #00d4ff;
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); }
}
/* Responsive Design */
@media (max-width: 768px) {
.container {
margin: 1rem;
padding: 2rem;
max-width: none;
}
.logo h1 {
font-size: 2rem;
}
.form-group input {
padding: 0.875rem;
}
.btn {
padding: 0.875rem;
}
}
@media (max-width: 480px) {
.container {
margin: 0.5rem;
padding: 1.5rem;
}
.logo h1 {
font-size: 1.75rem;
}
.logo p {
font-size: 0.875rem;
}
.back-button {
top: 15px;
right: 15px;
padding: 10px 15px;
font-size: 0.8rem;
}
}
</style>
</head>
<body>
<!-- Back to Home Button -->
<a href="/" class="back-button">Zur Hauptseite</a>
<div class="container">
<div class="logo">
<h1>🥷 NINJACROSS</h1>
<p>Dein Dashboard</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: #e2e8f0; font-weight: 600;">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>
<!-- Password Reset Container -->
<div id="passwordResetContainer" class="password-reset-container">
<p>Passwort vergessen? Kein Problem!</p>
<button type="button" id="resetPasswordBtn" class="btn btn-reset">Passwort zurücksetzen</button>
</div>
<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: #e2e8f0; font-weight: 600;">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 = '/';
}
}
// 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();
showPasswordReset(false); // Hide password reset when switching forms
}
// 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 password reset container
function showPasswordReset(show) {
const resetContainer = document.getElementById('passwordResetContainer');
if (show) {
resetContainer.classList.add('active');
} else {
resetContainer.classList.remove('active');
}
}
// 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();
showPasswordReset(false); // Hide reset button initially
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');
// Show password reset button on login failure
showPasswordReset(true);
} else {
showMessage('Login successful! Redirecting...', 'success');
setTimeout(() => {
window.location.href = '/';
}, 1000);
}
} catch (error) {
showMessage('An unexpected error occurred', 'error');
showPasswordReset(true);
} 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 = '/';
}, 1000);
}
}
} catch (error) {
showMessage('An unexpected error occurred', 'error');
} finally {
setLoading(false);
}
});
// Handle password reset
document.getElementById('resetPasswordBtn').addEventListener('click', async () => {
const email = document.getElementById('loginEmail').value;
if (!email) {
showMessage('Bitte geben Sie zuerst Ihre E-Mail-Adresse ein', 'error');
return;
}
setLoading(true);
clearMessage();
try {
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: `${window.location.origin}/reset-password.html`
});
if (error) {
showMessage('Fehler beim Senden der E-Mail: ' + error.message, 'error');
} else {
showMessage('Passwort-Reset-E-Mail wurde gesendet! Bitte überprüfen Sie Ihr E-Mail-Postfach.', 'success');
showPasswordReset(false);
}
} catch (error) {
showMessage('Ein unerwarteter Fehler ist aufgetreten', 'error');
} finally {
setLoading(false);
}
});
// Check authentication on page load
checkAuth();
</script>
</body>
</html>