feat(auth): required login barrier with 1-click demo access and session management
This commit is contained in:
@@ -15,8 +15,16 @@
|
||||
🥨 <span>Schmankerl</span> <small class="tenant-badge">{{ tenant.name if tenant else 'Portal' }}</small>
|
||||
</a>
|
||||
<nav class="nav-links">
|
||||
{% if current_user %}
|
||||
<a href="/">Brotzeit bestellen</a>
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a href="/admin" class="nav-admin">👨🍳 Einkäufer-Cockpit</a>
|
||||
{% endif %}
|
||||
<span class="user-greeting">👤 {{ current_user.first_name }}</span>
|
||||
<a href="/logout" class="nav-logout">Abmelden</a>
|
||||
{% else %}
|
||||
<a href="/login" class="nav-login">Anmelden</a>
|
||||
{% endif %}
|
||||
<a href="https://new.dev.waiswuaschd.de" target="_blank" class="nav-home">Zur Plattform</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
+23
-14
@@ -13,7 +13,7 @@
|
||||
Bestellschluss: <strong>{{ event.deadline.strftime('%d.%m.%Y um %H:%M Uhr') }}</strong>
|
||||
</p>
|
||||
<div class="banner-stats">
|
||||
<span>👥 Bereits <strong>{{ order_count }}</strong> Bestellungen eingegangen</span>
|
||||
<span>👥 Bereits <strong>{{ order_count }}</strong> Bestellungen von Kollegen eingegangen</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<h2>1. Brotzeit auswählen</h2>
|
||||
<div class="product-list">
|
||||
{% for product in products %}
|
||||
{% set current_qty = user_items.get(product.id, 0) %}
|
||||
<div class="product-card" data-price="{{ product.price }}" data-id="{{ product.id }}">
|
||||
<div class="product-info">
|
||||
<h3>{{ product.name }}</h3>
|
||||
@@ -35,7 +36,7 @@
|
||||
</div>
|
||||
<div class="quantity-control">
|
||||
<button type="button" class="qty-btn" onclick="changeQty({{ product.id }}, -1)">-</button>
|
||||
<input type="number" id="qty_{{ product.id }}" name="qty_{{ product.id }}" value="0" min="0" max="50" class="qty-input" onchange="updateTotal()">
|
||||
<input type="number" id="qty_{{ product.id }}" name="qty_{{ product.id }}" value="{{ current_qty }}" min="0" max="50" class="qty-input" onchange="updateTotal()">
|
||||
<button type="button" class="qty-btn" onclick="changeQty({{ product.id }}, 1)">+</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -46,19 +47,21 @@
|
||||
<!-- Right: User Details & Summary -->
|
||||
<div class="summary-section">
|
||||
<div class="summary-card">
|
||||
<h2>2. Deine Angaben</h2>
|
||||
<div class="input-group">
|
||||
<label for="first_name">Vorname</label>
|
||||
<input type="text" id="first_name" name="first_name" required placeholder="z. B. Maxi">
|
||||
<h2>2. Zusammenfassung</h2>
|
||||
|
||||
<div class="logged-in-badge">
|
||||
<div class="user-avatar">👤</div>
|
||||
<div>
|
||||
<strong>{{ current_user.first_name }} {{ current_user.last_name }}</strong><br>
|
||||
<small class="text-muted">{{ current_user.email }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="last_name">Nachname</label>
|
||||
<input type="text" id="last_name" name="last_name" required placeholder="z. B. Muster">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="email">E-Mail-Adresse</label>
|
||||
<input type="email" id="email" name="email" required placeholder="maxi@beispiel.de">
|
||||
|
||||
{% if existing_order %}
|
||||
<div class="notice-box">
|
||||
ℹ️ Du hast bereits für diese Runde bestellt. Du kannst deine Mengen hier anpassen und aktualisieren.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<hr class="divider">
|
||||
|
||||
@@ -68,9 +71,13 @@
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-submit" id="submitBtn">
|
||||
{% if existing_order %}
|
||||
🥨 Bestellung aktualisieren
|
||||
{% else %}
|
||||
🥨 Bestellung verbindlich abschicken
|
||||
{% endif %}
|
||||
</button>
|
||||
<small class="form-hint">Du kannst deine Bestellung bis zum Stichtag jederzeit mit derselben E-Mail-Adresse ändern.</small>
|
||||
<small class="form-hint">Du kannst deine Bestellung bis zum Stichtag jederzeit hier im Portal anpassen.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -81,7 +88,9 @@
|
||||
<div class="empty-icon">🏖️</div>
|
||||
<h2>Aktuell keine offene Bestellrunde</h2>
|
||||
<p>Für dieses Team ist im Moment keine Brotzeit geplant.</p>
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a href="/admin" class="btn-primary">Neue Bestellrunde im Cockpit anlegen</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Anmelden – Schmankerl{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container narrow">
|
||||
|
||||
<div class="login-box">
|
||||
<div class="login-header">
|
||||
<div class="login-icon">🥨</div>
|
||||
<h1>Anmeldung erforderlich</h1>
|
||||
<p class="login-sub">
|
||||
Portal: <strong>{{ tenant.name if tenant else 'Schmankerl' }}</strong>
|
||||
</p>
|
||||
<div class="privacy-note">
|
||||
🔒 Aus Datenschutzgründen (DSGVO) sind Bestelllisten und Teilnehmerdaten nur für angemeldete Teammitglieder sichtbar.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert-danger">{{ error }}</div>
|
||||
{% endif %}
|
||||
{% if success %}
|
||||
<div class="alert-success">{{ success }}</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- 1-Click Demo Login Box (For easy review & testing) -->
|
||||
<div class="demo-login-card">
|
||||
<h3>🚀 1-Klick Demo-Zugang</h3>
|
||||
<p class="card-hint">Wähle eine Rolle zum sofortigen Ausprobieren:</p>
|
||||
<div class="demo-btn-grid">
|
||||
<form action="/login/quick" method="POST">
|
||||
<input type="hidden" name="role" value="user">
|
||||
<button type="submit" class="btn-demo">
|
||||
👤 <strong>Mitarbeiter</strong><br>
|
||||
<small>Brotzeit bestellen & Übersicht</small>
|
||||
</button>
|
||||
</form>
|
||||
<form action="/login/quick" method="POST">
|
||||
<input type="hidden" name="role" value="admin">
|
||||
<button type="submit" class="btn-demo admin">
|
||||
👨🍳 <strong>Einkäufer / Admin</strong><br>
|
||||
<small>Sammelliste & Kasse verwalten</small>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tab Navigation -->
|
||||
<div class="auth-tabs">
|
||||
<button class="auth-tab active" id="tabLoginBtn" onclick="switchAuthTab('login')">Anmelden</button>
|
||||
<button class="auth-tab" id="tabRegisterBtn" onclick="switchAuthTab('register')">Neu registrieren</button>
|
||||
</div>
|
||||
|
||||
<!-- Login Form -->
|
||||
<form action="/login" method="POST" id="formLogin" class="auth-form">
|
||||
<div class="input-group">
|
||||
<label for="login_email">E-Mail-Adresse</label>
|
||||
<input type="email" id="login_email" name="email" required placeholder="name@firma.de">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="login_password">Passwort</label>
|
||||
<input type="password" id="login_password" name="password" required placeholder="••••••••">
|
||||
</div>
|
||||
<button type="submit" class="btn-submit">Anmelden</button>
|
||||
</form>
|
||||
|
||||
<!-- Register Form (Hidden by default) -->
|
||||
<form action="/register" method="POST" id="formRegister" class="auth-form" style="display: none;">
|
||||
<div class="input-group">
|
||||
<label for="reg_first_name">Vorname</label>
|
||||
<input type="text" id="reg_first_name" name="first_name" required placeholder="z. B. Anna">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="reg_last_name">Nachname</label>
|
||||
<input type="text" id="reg_last_name" name="last_name" required placeholder="z. B. Huber">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="reg_email">E-Mail-Adresse</label>
|
||||
<input type="email" id="reg_email" name="email" required placeholder="anna@firma.de">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="reg_password">Passwort festlegen</label>
|
||||
<input type="password" id="reg_password" name="password" required minlength="6" placeholder="Mindestens 6 Zeichen">
|
||||
</div>
|
||||
<button type="submit" class="btn-submit">Konto erstellen & anmelden</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function switchAuthTab(tab) {
|
||||
const loginForm = document.getElementById('formLogin');
|
||||
const regForm = document.getElementById('formRegister');
|
||||
const loginBtn = document.getElementById('tabLoginBtn');
|
||||
const regBtn = document.getElementById('tabRegisterBtn');
|
||||
|
||||
if (tab === 'login') {
|
||||
loginForm.style.display = 'block';
|
||||
regForm.style.display = 'none';
|
||||
loginBtn.classList.add('active');
|
||||
regBtn.classList.remove('active');
|
||||
} else {
|
||||
loginForm.style.display = 'none';
|
||||
regForm.style.display = 'block';
|
||||
loginBtn.classList.remove('active');
|
||||
regBtn.classList.add('active');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user