Password reset and UI fixes #2

Merged
alexandre merged 3 commits from password into master 2021-12-06 17:59:23 +01:00
5 changed files with 13 additions and 12 deletions
Showing only changes of commit d5a8445df3 - Show all commits

View File

@@ -1,10 +1,10 @@
from flask import Flask
from . import reset, config
from . import password, config
def create_app():
app = Flask(__name__, template_folder="ui/templates", static_folder="ui/static")
app.config.from_object(config.ProductionConfig())
app.register_blueprint(reset.bp)
app.register_blueprint(password.bp)
return app

View File

@@ -14,9 +14,9 @@ from wtforms.validators import (
EqualTo, Length, Regexp
)
bp = Blueprint('reset', __name__, url_prefix='/reset')
bp = Blueprint('password', __name__, url_prefix='/password')
class ResetPasswordForm(FlaskForm):
class ChangePasswordForm(FlaskForm):
# Minimal password length
minlength = 9
@@ -54,11 +54,12 @@ class ResetPasswordForm(FlaskForm):
raise ValidationError(
f"Character {char} is not allowed in an username.")
@bp.route('/', methods=('GET', 'POST'))
def reset():
form = ResetPasswordForm()
@bp.route('/change', methods=('GET', 'POST'))
def change():
form = ChangePasswordForm()
if form.validate_on_submit():
client = ldap_client.Client(address=current_app.config["LDAP_ADDR"], port=current_app.config["LDAP_PORT"], base_dn=current_app.config["BASE_DN"], tls=current_app.config["LDAP_TLS"])
bind_status = client.bind(form.username._value(), form.currentpassword._value())
if bind_status[0] == False:
flash(f"Connection failed, are you sure that your login and password are correct ? ({client.link.last_error})")
@@ -69,4 +70,4 @@ def reset():
flash('Your password has been changed !')
client.unbind()
return render_template('reset.html', form=form)
return render_template('change.html', form=form)

View File

@@ -93,7 +93,7 @@ li.errormsg::before {
-webkit-box-shadow: 0 0 0 .10rem rgba(92, 184, 92, 0.50);
}
#reset-form {
#change-form {
background: #4e4e4e;
border-radius: .50rem;
}

View File

@@ -11,7 +11,7 @@
<link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png">
<link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap">
<link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="/static/css/main.css" crossorigin="anonymous" integrity="sha384-fkK5tYaqbiUHGwmnlK0EawjBjKHQW0raxLDNOyZDFdHQL819ZrrviEpqz6P53tyX">
<link rel="stylesheet" href="/static/css/main.css" crossorigin="anonymous" integrity="sha384-1mUptOXBpF6Jmz5VBNmsieaTKvJrMrSSLQNb/S1TJ7zYE1QS3fCuO3RZJQDSwBD6">
</head>
<body>
{% for message in get_flashed_messages() %}

View File

@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block main_block %}
<div class="row col-md" id="reset-form">
<div class="row col-md" id="change-form">
<form method="post">
{{ form.csrf_token() }}
<div class="form-group">
@@ -45,4 +45,4 @@
{% block script_block %}
<script defer src="/static/js/validate.js"></script>
{% endblock script_block %}
{% endblock script_block %}