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