Commit ee939716 authored by Martin Mareš's avatar Martin Mareš
Browse files

Authentication tokens renamed to access keys (except in DB schema)

Closes #22.
parent 2cc77b94
......@@ -3,7 +3,7 @@ SET ROLE owl;
CREATE TABLE owl_users (
uid serial PRIMARY KEY,
ukco int UNIQUE DEFAULT NULL,
auth_token varchar(64) UNIQUE DEFAULT NULL,
auth_token varchar(64) UNIQUE DEFAULT NULL, -- this is called "access key" in UI
full_name varchar(255) NOT NULL,
email varchar(255) DEFAULT NULL,
-- we allow CAS's format "{email1,email2,...}"
......
......@@ -1294,7 +1294,7 @@ def admin_courses():
class TokenLoginForm(FlaskForm):
next = wtforms.HiddenField()
token = wtforms.PasswordField("Token", validators=[validators.DataRequired()])
key = wtforms.PasswordField("Token", validators=[validators.DataRequired()])
@app.route('/login/', methods=('GET', 'POST'))
......@@ -1304,15 +1304,15 @@ def login():
if not form.validate_on_submit():
return render_template('login.html', form=form, error=None)
db_query("SELECT * FROM owl_users WHERE auth_token=%s", (form.token.data,))
db_query("SELECT * FROM owl_users WHERE auth_token=%s", (form.key.data,))
row = db.fetchone()
if row:
app.logger.info('Logged in user: uid=%s, cn=%s, admin=%s by token', row.uid, row.full_name, row.is_admin)
app.logger.info('Logged in user: uid=%s, cn=%s, admin=%s by key', row.uid, row.full_name, row.is_admin)
session_from_db(row)
return redirect(form.next.data or url_for('index'))
app.logger.info('Invalid login token')
return render_template('login.html', form=form, error='Invalid token')
app.logger.info('Invalid login key')
return render_template('login.html', form=form, error='Invalid access key')
@app.route('/login/cas', methods=('GET', 'POST'))
......
......@@ -14,7 +14,7 @@
<form method="POST" action="?">
{{ form.csrf_token }}
{{ form.next() }}
Login by token: {{ form.token(size=64) }}
Login by access key: {{ form.key(size=64) }}
<input type=submit value='Go!'>
</form>
......
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