forked from moepman/bk-dss
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():
|
if isLoggedin():
|
||||||
nav.append('edit')
|
nav.append('edit')
|
||||||
if isAdmin():
|
if isAdmin():
|
||||||
|
nav.append('list')
|
||||||
nav.append('create')
|
nav.append('create')
|
||||||
nav.append('logout')
|
nav.append('logout')
|
||||||
else:
|
else:
|
||||||
@ -140,6 +141,17 @@ def edit():
|
|||||||
return render_template('edit.html', form=form, nav=buildNav())
|
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'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
form = LoginForm()
|
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