Commit 02fd123a authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

flashing icorporated

parent ca4000a3
......@@ -33,6 +33,19 @@
</head>
{% block content %} {% endblock %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible show fade" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<footer class="py-5">
<div class="container">
......
......@@ -86,7 +86,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-single-02"></i></span>
</div>
<input class="form-control" maxlength="30" placeholder="Username" type="text" id="username" name="username">
<input class="form-control" maxlength="30" placeholder="Username" type="text" id="username" name="username" required>
</div>
</div>
<div class="form-group">
......
......@@ -41,7 +41,7 @@ def index():
@app.route('/register', methods=['GET', 'POST'])
def signup():
def register():
if request.method == 'GET':
if 'role' in session and session['role'] == 'admin':
return render_template('old/admin/signup.html', users_signup=app.config['USERS_SIGNUP'])
......@@ -56,11 +56,11 @@ def signup():
password = request.form['password'].encode('utf-8')
if (username == '' or password == ''):
feedback = 'Username or password fields cannot be empty'
return render_template('old/public/signup.html', feedback=feedback, users_signup=app.config['USERS_SIGNUP'])
flash('Username or password fields cannot be empty', 'danger')
return redirect(url_for('register', users_signup=app.config['USERS_SIGNUP']))
elif (len(password) < 8):
flash('Password length must be at least 8 characters.', 'danger')
return redirect(request.url, users_signup=app.config['USERS_SIGNUP'])
return redirect(url_for('register', users_signup=app.config['USERS_SIGNUP']))
else:
role = 'user'
if 'role' in request.form and request.form['role'] == 'administrator':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment