Commit 841c3ab9 authored by Mathis Dedial's avatar Mathis Dedial
Browse files

Try to fix LDAP login

parent 67ac8638
Pipeline #2723 skipped with stage
......@@ -33,6 +33,11 @@ class BurgerUser(UserMixin):
return self.nethz
@login_manager.user_loader
def load_burger_user(nethz):
return BurgerUser(nethz)
@app.before_request
def set_ldap_test_user():
'''
......
......@@ -24,7 +24,7 @@ def index():
'LEFT JOIN vote AS vote_2 ON vote_2.burger_id=burger.id AND vote_2.nethz= :nethz '
'GROUP BY burger.id '
'ORDER BY vote_count DESC, timestamp')
burger_list = db.engine.execute(querystring, nethz=g.user).fetchall()
burger_list = db.engine.execute(querystring, nethz=getattr(g, 'user', '')).fetchall()
return render_template('vote.html',
burger_list=burger_list,
bread=BREAD,
......@@ -86,7 +86,7 @@ def login():
'''
Login page. LDAP-Login only.
'''
if g.user:
if getattr(g, 'user', None):
return redirect(url_for('index'))
if request.method == 'POST':
user = request.form['user']
......@@ -96,6 +96,7 @@ def login():
if test is None or passwd == '':
flash('Invalid credentials', 'error')
else:
setattr(g, 'user', user)
# Create instance of BurgerUser
burger_user = BurgerUser(user)
# Log in BurgerUser
......
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