Zadanie 4
This commit is contained in:
parent
3646626805
commit
ee946112d7
@ -1,5 +1,5 @@
|
|||||||
import flask
|
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 os
|
||||||
import traceback
|
import traceback
|
||||||
import json
|
import json
|
||||||
@ -85,7 +85,8 @@ def register():
|
|||||||
|
|
||||||
# Walidacja hasła: min. 8 znaków i min. jedna cyfra
|
# Walidacja hasła: min. 8 znaków i min. jedna cyfra
|
||||||
if len(password) < 8 or not any(char.isdigit() for char in password):
|
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)
|
user = User(username, nickname, password)
|
||||||
sqlsession.add(user)
|
sqlsession.add(user)
|
||||||
|
|||||||
@ -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">
|
<form action="/register" method="POST">
|
||||||
<div class="login">
|
<div class="login">
|
||||||
<div class="login-screen">
|
<div class="login-screen">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user