mirror of
https://github.com/moepman/bk-dss
synced 2024-12-22 08:04:27 +01:00
Implement user listing.
This commit is contained in:
parent
dc2afe0e2a
commit
89a8cecb2a
12
index.py
12
index.py
@ -55,6 +55,7 @@ def buildNav():
|
||||
if isLoggedin():
|
||||
nav.append('edit')
|
||||
if isAdmin():
|
||||
nav.append('list')
|
||||
nav.append('create')
|
||||
nav.append('logout')
|
||||
else:
|
||||
@ -140,6 +141,17 @@ def edit():
|
||||
return render_template('edit.html', form=form, nav=buildNav())
|
||||
|
||||
|
||||
@app.route('/list')
|
||||
def list():
|
||||
if not isLoggedin():
|
||||
return render_template('error.html', message="You are not logged in. Please log in first.", nav=buildNav())
|
||||
|
||||
l = ldap.initialize(app.config.get('LDAP_URI', 'ldaps://127.0.0.1'))
|
||||
l.simple_bind_s(rdb.hget(session['uuid'], 'user'), rdb.hget(session['uuid'], 'pswd'))
|
||||
sr = l.search_s(app.config.get('LDAP_BASE'), ldap.SCOPE_SUBTREE, '(objectClass=posixAccount)', [''])
|
||||
return render_template('list.html', users=sr, nav=buildNav())
|
||||
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
form = LoginForm()
|
||||
|
16
templates/list.html
Normal file
16
templates/list.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends "_base.html" %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>List users</h1>
|
||||
</div>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr><td>DN</td></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for dn, _ in users %}
|
||||
<tr><td>{{ dn }}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user