Compare commits

...

1 Commits

Author SHA1 Message Date
Tim Van Baak 94e91d6b3e Add more logging 2021-02-18 22:34:38 -08:00
2 changed files with 16 additions and 9 deletions

View File

@ -42,7 +42,7 @@ class Admin(UserMixin):
class LoginForm(FlaskForm): class LoginForm(FlaskForm):
password = PasswordField('Password', validators=[DataRequired()]) password = PasswordField('Password')
submit = SubmitField('Submit') submit = SubmitField('Submit')
@ -105,9 +105,19 @@ def document(document_id):
@app.route('/login/', methods=['GET', 'POST']) @app.route('/login/', methods=['GET', 'POST'])
def login(): def login():
form = LoginForm() form = LoginForm()
if form.validate_on_submit() and check_password(current_app, form.password.data): s = form.is_submitted()
login_user(Admin()) logger.debug(f's={s}')
return redirect(url_for('index')) if s:
logger.debug(f'pw={form.password.data}')
logger.debug(f'headers={request.headers}')
v = form.validate()
logger.debug(f'v={v}')
logger.debug(f'e={form.errors}')
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) return render_template('login.jinja', form=form)
@ -233,5 +243,5 @@ def wsgi():
config_path = os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf' config_path = os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf'
config = read_config(app, config_path) config = read_config(app, config_path)
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
logger.debug(f'Loaded config from {config_path}: {config}') logger.debug(f'Lloaded config from {config_path}: {config}')
return app return app

View File

@ -8,12 +8,9 @@
<div id="index" class="tab tab-right"><a href="/index/">index</a></div> <div id="index" class="tab tab-right"><a href="/index/">index</a></div>
</div> </div>
<div class="tab-page tab-page-selected"> <div class="tab-page tab-page-selected">
<form action="" method="post" novalidate> <form method="post" novalidate>
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p>{{ form.password.label }}<br>{{ form.password(size=32) }} <p>{{ form.password.label }}<br>{{ form.password(size=32) }}
{% for error in form.password.errors %}
<br><span style="color: #ff0000">{{ error }}</span>
{% endfor %}</p>
<p>{{ form.submit() }}</p> <p>{{ form.submit() }}</p>
</form> </form>
</div> </div>