bug fixes
All checks were successful
Build and Push Madplaner / build (push) Successful in 26s
All checks were successful
Build and Push Madplaner / build (push) Successful in 26s
This commit is contained in:
22
app.py
22
app.py
@@ -201,22 +201,26 @@ def login():
|
|||||||
if user and check_password_hash(user.password, request.form.get("password")):
|
if user and check_password_hash(user.password, request.form.get("password")):
|
||||||
login_user(user)
|
login_user(user)
|
||||||
return redirect(url_for("dashboard"))
|
return redirect(url_for("dashboard"))
|
||||||
flash("Invalid credentials")
|
flash("Invalid credentials",'error')
|
||||||
return render_template("login.html")
|
return render_template("login.html")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/register", methods=["GET", "POST"])
|
@app.route("/register", methods=["GET", "POST"])
|
||||||
def register():
|
def register():
|
||||||
if request.method == "POST":
|
if request.method == 'POST':
|
||||||
new_user = User(
|
username = request.form.get('username')
|
||||||
username=request.form.get("username"),
|
password = request.form.get('password')
|
||||||
password=generate_password_hash(
|
|
||||||
request.form.get("password"), method="pbkdf2:sha256"
|
existing_user = User.query.filter_by(username=username).first()
|
||||||
),
|
|
||||||
)
|
if existing_user:
|
||||||
|
flash('That username is already taken. Please choose a different one.', 'error')
|
||||||
|
return redirect(url_for('register'))
|
||||||
|
|
||||||
|
new_user = User(username=username, password=generate_password_hash(password))
|
||||||
db.session.add(new_user)
|
db.session.add(new_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("/"))
|
return redirect(url_for("dashboard"))
|
||||||
return render_template("register.html")
|
return render_template("register.html")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,11 @@
|
|||||||
<a href="/dashboard" class="text-sm font-medium text-stone-600 hover:text-emerald-800 transition-colors">Dashboard</a>
|
<a href="/dashboard" class="text-sm font-medium text-stone-600 hover:text-emerald-800 transition-colors">Dashboard</a>
|
||||||
<div class="h-4 w-px bg-stone-200"></div>
|
<div class="h-4 w-px bg-stone-200"></div>
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<span class="text-sm text-stone-400 font-light">Hej, {{ current_user.username }}</span>
|
|
||||||
<a href="/logout" class="text-sm font-medium bg-stone-100 text-stone-900 px-4 py-2 rounded-full hover:bg-stone-200 transition-all">Sign Out</a>
|
<a href="/logout" class="text-sm font-medium bg-stone-100 text-stone-900 px-4 py-2 rounded-full hover:bg-stone-200 transition-all">Sign Out</a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/login" class="text-sm font-medium text-stone-600 hover:text-stone-900">Login</a>
|
<a href="/login" class="text-sm font-medium text-stone-600 hover:text-stone-900">Login</a>
|
||||||
<a href="/register" class="text-sm font-medium bg-emerald-800 text-white px-6 py-2.5 rounded-full hover:bg-emerald-900 shadow-sm transition-all">Join Free</a>
|
<a href="/register" class="text-sm font-medium bg-emerald-800 text-white px-6 py-2.5 rounded-full hover:bg-emerald-900 shadow-sm transition-all">Register</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -76,33 +75,5 @@
|
|||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
function showToast(message, type = 'success') {
|
|
||||||
const container = document.getElementById('toast-container');
|
|
||||||
const toast = document.createElement('div');
|
|
||||||
|
|
||||||
// Nordic Palette for Toasts
|
|
||||||
const styles = type === 'success'
|
|
||||||
? 'bg-white border-emerald-500 text-stone-800'
|
|
||||||
: 'bg-white border-rose-500 text-stone-800';
|
|
||||||
|
|
||||||
const icon = type === 'success'
|
|
||||||
? '<span class="text-emerald-500 text-lg">✓</span>'
|
|
||||||
: '<span class="text-rose-500 text-lg">✕</span>';
|
|
||||||
|
|
||||||
toast.className = `toast-animate-in pointer-events-auto flex items-center gap-4 px-6 py-4 rounded-2xl shadow-xl border-l-4 ${styles} min-w-[300px]`;
|
|
||||||
|
|
||||||
toast.innerHTML = `
|
|
||||||
${icon}
|
|
||||||
<p class="text-sm font-medium tracking-tight">${message}</p>
|
|
||||||
`;
|
|
||||||
|
|
||||||
container.appendChild(toast);
|
|
||||||
|
|
||||||
// Auto-remove after 4 seconds
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.classList.replace('toast-animate-in', 'toast-animate-out');
|
|
||||||
setTimeout(() => toast.remove(), 300);
|
|
||||||
}, 4000);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
<a href="/dashboard"
|
<a href="/dashboard"
|
||||||
class="bg-stone-900 text-stone-50 px-10 py-4 rounded-full font-medium transition-all hover:bg-stone-800 hover:shadow-xl active:scale-95 flex items-center gap-3">
|
class="bg-emerald-800 text-stone-50 px-10 py-4 rounded-full font-medium transition-all hover:bg-stone-800 hover:shadow-xl active:scale-95 flex items-center gap-3">
|
||||||
Open Dashboard
|
Open Dashboard
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17 8l4 4m0 0l-4 4m4-4H3" />
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17 8l4 4m0 0l-4 4m4-4H3" />
|
||||||
|
|||||||
@@ -6,15 +6,6 @@
|
|||||||
<p class="text-gray-500 mt-2">Få madplaner tilpasset dine ønsker i dag.</p>
|
<p class="text-gray-500 mt-2">Få madplaner tilpasset dine ønsker i dag.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% with messages = get_flashed_messages() %}
|
|
||||||
{% if messages %}
|
|
||||||
{% for message in messages %}
|
|
||||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
|
||||||
{{ message }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
<form method="POST" id="registerForm">
|
<form method="POST" id="registerForm">
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user