last_used only updates the key that was used
This commit is contained in:
parent
448b5048d8
commit
06cf8161e9
4
auth.py
4
auth.py
|
@ -53,8 +53,8 @@ def auth_required(func):
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"UPDATE user_session SET last_used = NOW(), "
|
"UPDATE user_session SET last_used = NOW(), "
|
||||||
"expires = NOW() + INTERVAL '30 DAYS' "
|
"expires = NOW() + INTERVAL '30 DAYS' "
|
||||||
"WHERE user_id = $1",
|
"WHERE user_id = $1 AND id = $2",
|
||||||
user_id)
|
user_id, sid)
|
||||||
resp.set_cookie(
|
resp.set_cookie(
|
||||||
'userid',
|
'userid',
|
||||||
user_id,
|
user_id,
|
||||||
|
|
12
buckler.py
12
buckler.py
|
@ -224,13 +224,11 @@ async def get_session(request):
|
||||||
app = await conn.fetchrow("SELECT * FROM app_info WHERE id = $1", app_id)
|
app = await conn.fetchrow("SELECT * FROM app_info WHERE id = $1", app_id)
|
||||||
if app:
|
if app:
|
||||||
if argon2.verify(app_key, app['key_hash']):
|
if argon2.verify(app_key, app['key_hash']):
|
||||||
sessions = await conn.fetch(
|
session = await conn.fetchrow(
|
||||||
"SELECT * FROM user_session "
|
"SELECT * FROM user_session "
|
||||||
"WHERE user_id = $1 AND expires > NOW()",
|
"WHERE user_id = $1 AND id = $2 AND expires > NOW()",
|
||||||
user_id)
|
user_id, user_sid)
|
||||||
session = [s for s in sessions if s.get('id') == user_sid]
|
|
||||||
if session:
|
if session:
|
||||||
session = session[0]
|
|
||||||
data = await conn.fetchrow(
|
data = await conn.fetchrow(
|
||||||
"SELECT user_info.username, app_user.session_data "
|
"SELECT user_info.username, app_user.session_data "
|
||||||
"FROM user_info LEFT JOIN app_user "
|
"FROM user_info LEFT JOIN app_user "
|
||||||
|
@ -244,8 +242,8 @@ async def get_session(request):
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"UPDATE user_session SET last_used = NOW(), "
|
"UPDATE user_session SET last_used = NOW(), "
|
||||||
"expires = NOW() + INTERVAL '30 DAYS' "
|
"expires = NOW() + INTERVAL '30 DAYS' "
|
||||||
"WHERE user_id = $1",
|
"WHERE user_id = $1 AND id = $2",
|
||||||
user_id)
|
user_id, user_sid)
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
|
||||||
data_meta = dict(data)
|
data_meta = dict(data)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user