fix delete_session()

This commit is contained in:
iou1name 2020-08-14 23:47:25 -04:00
parent 8060d84ac2
commit 85c0f37e17
2 changed files with 5 additions and 4 deletions

View File

@ -30,7 +30,7 @@ def auth_required(func):
login_url = request.app.router['login'].url_for()
sid = request.cookies.get('session')
try:
user_id = int(request.cookies.get('userid', '0'))
user_id = int(request.cookies.get('userid'))
except (ValueError, TypeError):
user_id = None
if not sid or not user_id:

View File

@ -38,11 +38,11 @@ async def index(request):
'new_app': forms.new_app,
'change_password': forms.change_password,
'delete_key': forms.delete_key,
'delele_session': forms.delete_session,
'delete_session': forms.delete_session,
}
if not forms_.get(form):
errors = {'main': "Unknown form id: {form}"}
errors = {'main': f"Unknown form id: {form}"}
else:
errors = await forms_[form](request)
@ -65,7 +65,8 @@ 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 AND expires > NOW() "
"ORDER BY last_used DESC",
request['session']['id'])
if request['session']['admin']: