Commit 38d3345c authored by Julian Rother's avatar Julian Rother
Browse files

Added user indication

parent 56c9bde6
......@@ -90,6 +90,19 @@ def ldapauth(user, password):
return user, notldap[user][1]
return None, []
def ldapget(user):
notldap = {'videoag': {'uid': 'videoag', 'givenName': 'Video', 'sn': 'Geier'},
'gustav': {'uid': 'gustav', 'givenName': 'Gustav', 'sn': 'Geier'}}
user = LDAP_USERRE.sub(r'', user.lower())
if 'LDAP_HOST' in config:
conn = ldap3.Connection('ldaps://rumo.fsmpi.rwth-aachen.de', auto_bind=True)
conn.search("ou=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(uid=%s)"%user,
attributes=ldap3.ALL_ATTRIBUTES)
e = conn.entries[0]
return {'uid': user, 'givenName': e.givenName.value, 'sn':e.sn.value}
else:
return notldap[user]
@app.route('/')
def index():
return render_template('index.html', latestvideos=query('''
......@@ -156,7 +169,7 @@ def course():
def login():
user, groups = ldapauth(request.form.get('user'), request.form.get('password'))
if user and 'users' in groups:
session['user'] = user
session['user'] = ldapget(user)
if 'ref' in request.values:
return redirect(request.values['ref'])
else:
......
......@@ -71,6 +71,7 @@
</script>
{% else %}
<a href="/logout?ref={{ request.url|urlencode }}">
{{ session.user.givenName }}
<span class="glyphicon glyphicon-log-out"></span>
</a>
{% endif %}
......
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