diff --git a/app/__init__.py b/app/__init__.py index ebedb5f..33a09db 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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 diff --git a/app/reset.py b/app/password.py similarity index 88% rename from app/reset.py rename to app/password.py index f6036fd..d8afd66 100644 --- a/app/reset.py +++ b/app/password.py @@ -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) \ No newline at end of file + return render_template('change.html', form=form) diff --git a/app/ui/static/css/main.css b/app/ui/static/css/main.css index b0faa5f..9e4542f 100644 --- a/app/ui/static/css/main.css +++ b/app/ui/static/css/main.css @@ -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; } diff --git a/app/ui/templates/base.html b/app/ui/templates/base.html index 70d2ffb..4ad51cb 100644 --- a/app/ui/templates/base.html +++ b/app/ui/templates/base.html @@ -11,7 +11,7 @@ - + {% for message in get_flashed_messages() %} diff --git a/app/ui/templates/reset.html b/app/ui/templates/change.html similarity index 93% rename from app/ui/templates/reset.html rename to app/ui/templates/change.html index b593e02..529d1bd 100644 --- a/app/ui/templates/reset.html +++ b/app/ui/templates/change.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block main_block %} -
+
{{ form.csrf_token() }}
@@ -45,4 +45,4 @@ {% block script_block %} -{% endblock script_block %} \ No newline at end of file +{% endblock script_block %}