Zadanie 4

This commit is contained in:
Mikołaj Kaczmarek 2025-06-15 22:08:47 +02:00
parent 3646626805
commit ee946112d7
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import flask
from flask import Flask, render_template, request, session
from flask import Flask, render_template, request, session, flash, redirect, url_for
import os
import traceback
import json
@ -85,7 +85,8 @@ def register():
# Walidacja hasła: min. 8 znaków i min. jedna cyfra
if len(password) < 8 or not any(char.isdigit() for char in password):
return "<h2>Hasło musi mieć co najmniej 8 znaków i zawierać przynajmniej jedną cyfrę!</h2>", 400
flash("Hasło musi mieć co najmniej 8 znaków i zawierać przynajmniej jedną cyfrę!", "error")
return redirect(url_for("signup"))
user = User(username, nickname, password)
sqlsession.add(user)

View File

@ -1,4 +1,14 @@
<link rel="stylesheet" href="/static/style.css" type="text/css"> {% block body %}
<link rel="stylesheet" href="/static/style.css" type="text/css">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul class="flashes">
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% block body %}
<form action="/register" method="POST">
<div class="login">
<div class="login-screen">