Compare commits
No commits in common. "0f8f691a3ec1e0883bdd9e3918882fcca744507b" and "06cf8161e9ac1244c1b9fb6b837d7a9d10b1afa9" have entirely different histories.
0f8f691a3e
...
06cf8161e9
28
buckler.py
28
buckler.py
|
@ -45,7 +45,7 @@ async def index(request):
|
|||
request['session']['id'])
|
||||
active_sessions = await conn.fetch(
|
||||
"SELECT id, ip_address, date_created, last_used FROM user_session "
|
||||
"WHERE user_id = $1 ORDER BY last_used DESC",
|
||||
"WHERE user_id = $1",
|
||||
request['session']['id'])
|
||||
|
||||
if request['session']['admin']:
|
||||
|
@ -58,33 +58,11 @@ async def index(request):
|
|||
return render_template("index.html", request, locals())
|
||||
|
||||
|
||||
@routes.post(config.url_prefix + '/change_password', name='change_password')
|
||||
@routes.get(config.url_prefix + '/change_password', name='change_password')
|
||||
@auth.auth_required
|
||||
async def change_password(request):
|
||||
"""Allows a user to change their password."""
|
||||
data = await request.post()
|
||||
current_pw = data.get('current_password')
|
||||
new_pw = data.get('new_password')
|
||||
verify_pw = data.get('verify_password')
|
||||
|
||||
if not all(current_pw, new_pw, verify_pw):
|
||||
return
|
||||
if not new_pw == verify_pw:
|
||||
return
|
||||
|
||||
async with request.app['pool'].acquire() as conn:
|
||||
pw_hash = conn.fetchrow(
|
||||
"SELECT password_hash FROM user_info WHERE id = $1",
|
||||
request['session']['id'])
|
||||
if not argon2.verify(current_pw, pw_hash['password_hash']):
|
||||
return
|
||||
h = argon2.hash(new_pw)
|
||||
conn.execute(
|
||||
"UPDATE user_info SET password_hash = $1 WHERE id = $2",
|
||||
h, request['session']['id'])
|
||||
index_url = request.app.router['index'].url_for()
|
||||
raise web.HTTPFound(location=index_url)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@routes.get(config.url_prefix + '/login', name='login')
|
||||
|
|
|
@ -3,7 +3,6 @@ body {
|
|||
margin-right: 10%;
|
||||
background-color: lightgray;
|
||||
font-family: Helvetica,sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
header {
|
||||
|
@ -30,21 +29,12 @@ main section {
|
|||
0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.sub_section {
|
||||
box-shadow: none;
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#avail_sites {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
|
@ -64,17 +54,3 @@ tr {
|
|||
td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#change_password {
|
||||
border: none;
|
||||
border-collapse: separate;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#change_password tr {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#change_password td {
|
||||
text-align: left;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
function load() {
|
||||
let headers = document.querySelectorAll('h2');
|
||||
headers = Array.prototype.slice.call(headers);
|
||||
let headers3 = document.querySelectorAll('h3');
|
||||
headers3 = Array.prototype.slice.call(headers3);
|
||||
headers = headers.concat(headers3);
|
||||
|
||||
headers.forEach(function(header) {
|
||||
header.addEventListener('click', function() {
|
||||
let article = this.nextElementSibling;
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
</section>
|
||||
{% if request['session']['admin'] %}
|
||||
<section>
|
||||
<h2>Admin Panel</h2>
|
||||
<article style="display: none;">
|
||||
<section class="sub_section">
|
||||
<h3>User Permissions</h3>
|
||||
<h2>User Permissions</h2>
|
||||
<article style="display: none;">
|
||||
<hr>
|
||||
<table id="users">
|
||||
|
@ -60,28 +57,18 @@
|
|||
</table>
|
||||
</article>
|
||||
</section>
|
||||
</article>
|
||||
</section>
|
||||
{% endif %}
|
||||
<section>
|
||||
<h2>Change Password</h2>
|
||||
<article style="display: none;">
|
||||
<hr>
|
||||
<form action="{{ request.app.router['change_password'].url_for() }}" method="post" enctype="application/x-www-form-urlencoded">
|
||||
<table id="change_password">
|
||||
<tr>
|
||||
<td><label for="current_password">Current password</label></td>
|
||||
<td><input id="current_password" name="current_password" type="password"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="new_password">New password</label></td>
|
||||
<td><input id="new_password" name="new_password" type="password"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="verify_password">Verify password</label></td>
|
||||
<td><input id="verify_password" name="verify_password" type="password"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<label for="current_password">Current password</label>
|
||||
<input id="current_password" name="current_password" type="password"><br>
|
||||
<label for="new_password">New password</label>
|
||||
<input id="new_password" name="new_password" type="password"><br>
|
||||
<label for="verify_password">Verify password</label>
|
||||
<input id="verify_password" name="verify_password" type="password"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</article>
|
||||
|
|
Loading…
Reference in New Issue
Block a user