From a8ba428e1f2f206c6a6714513b5a77b3da331934 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 18 Feb 2021 19:17:43 -0800 Subject: [PATCH] Add more logging --- redstring/server.py | 18 +++++++++++++----- redstring/templates/login.jinja | 5 +---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/redstring/server.py b/redstring/server.py index 6be5a28..6493140 100644 --- a/redstring/server.py +++ b/redstring/server.py @@ -42,7 +42,7 @@ class Admin(UserMixin): class LoginForm(FlaskForm): - password = PasswordField('Password', validators=[DataRequired()]) + password = PasswordField('Password') submit = SubmitField('Submit') @@ -105,9 +105,17 @@ def document(document_id): @app.route('/login/', methods=['GET', 'POST']) def login(): form = LoginForm() - if form.validate_on_submit() and check_password(current_app, form.password.data): - login_user(Admin()) - return redirect(url_for('index')) + s = form.is_submitted() + logger.debug(f's={s}') + if s: + logger.debug(form.password.data) + v = form.validate() + logger.debug(f'v={v}') + if v: + valid = check_password(current_app, form.password.data) + if valid: + login_user(Admin()) + return redirect(url_for('index')) return render_template('login.jinja', form=form) @@ -233,5 +241,5 @@ def wsgi(): config_path = os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf' config = read_config(app, config_path) logger.setLevel(logging.DEBUG) - logger.debug(f'Loaded config from {config_path}: {config}') + logger.debug(f'Lloaded config from {config_path}: {config}') return app diff --git a/redstring/templates/login.jinja b/redstring/templates/login.jinja index 972c1af..637df99 100644 --- a/redstring/templates/login.jinja +++ b/redstring/templates/login.jinja @@ -8,12 +8,9 @@
index
-
+ {{ form.hidden_tag() }}

{{ form.password.label }}
{{ form.password(size=32) }} - {% for error in form.password.errors %} -
{{ error }} - {% endfor %}

{{ form.submit() }}