add active sessions section

This commit is contained in:
iou1name 2019-09-25 15:00:29 -04:00
parent e3c33a7492
commit a93a178b57
2 changed files with 29 additions and 3 deletions

View File

@ -44,6 +44,10 @@ async def index(request):
fido2_keys = await conn.fetch( fido2_keys = await conn.fetch(
"SELECT * FROM user_credential WHERE user_id = $1", "SELECT * FROM user_credential WHERE user_id = $1",
request['session']['id']) request['session']['id'])
active_sessions = await conn.fetch(
"SELECT ip_address FROM user_session "
"WHERE user_id = $1",
request['session']['id'])
if request['session']['admin']: if request['session']['admin']:
apps = [app['name'] for app in apps] apps = [app['name'] for app in apps]

View File

@ -29,7 +29,7 @@
{% if request['session']['admin'] %} {% if request['session']['admin'] %}
<section> <section>
<h2>User Permissions</h2> <h2>User Permissions</h2>
<article> <article style="display: none;">
<hr> <hr>
<table id="users"> <table id="users">
<thead> <thead>
@ -58,7 +58,7 @@
{% endif %} {% endif %}
<section> <section>
<h2>Change Password</h2> <h2>Change Password</h2>
<article> <article style="display: none;">
<hr> <hr>
<form action="{{ request.app.router['change_password'].url_for() }}" method="post" enctype="application/x-www-form-urlencoded"> <form action="{{ request.app.router['change_password'].url_for() }}" method="post" enctype="application/x-www-form-urlencoded">
<label for="current_password">Current password</label> <label for="current_password">Current password</label>
@ -73,7 +73,7 @@
</section> </section>
<section> <section>
<h2>Security Keys</h2> <h2>Security Keys</h2>
<article> <article style="display: none;">
<hr> <hr>
{% if fido2_keys %} {% if fido2_keys %}
<table id="security_keys"> <table id="security_keys">
@ -98,6 +98,28 @@
<br><a href="./add_key">Add key</a> <br><a href="./add_key">Add key</a>
</article> </article>
</section> </section>
<section>
<h2>Active Sessions</h2>
<article style="display: none;">
<hr>
<table id="active_sessions">
<thead>
<tr>
<th>IP Address</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for session in active_sessions %}
<tr>
<td>{{ session['ip_address'] }}</td>
<td><input type="checkbox"></td>
</tr>
{% endfor %}
</tbody>
</table>
</article>
</section>
</main> </main>
</body> </body>
</html> </html>