mirror of https://gitlab.com/litecord/litecord.git
auth: move last_session update from gateway to auth
this should help in cases where the client has long-lived sessions (more than a day)
This commit is contained in:
parent
80c29265f3
commit
4d4b075de9
|
|
@ -35,6 +35,17 @@ async def raw_token_check(token, db=None):
|
||||||
try:
|
try:
|
||||||
signer.unsign(token)
|
signer.unsign(token)
|
||||||
log.debug('login for uid {} successful', user_id)
|
log.debug('login for uid {} successful', user_id)
|
||||||
|
|
||||||
|
# update the user's last_session field
|
||||||
|
# so that we can keep an exact track of activity,
|
||||||
|
# even on long-lived single sessions (that can happen
|
||||||
|
# with people leaving their clients open forever)
|
||||||
|
await db.execute("""
|
||||||
|
UPDATE users
|
||||||
|
SET last_session = (now() at time zone 'utc')
|
||||||
|
WHERE id = $1
|
||||||
|
""", user_id)
|
||||||
|
|
||||||
return user_id
|
return user_id
|
||||||
except BadSignature:
|
except BadSignature:
|
||||||
log.warning('token failed for uid {}', user_id)
|
log.warning('token failed for uid {}', user_id)
|
||||||
|
|
|
||||||
|
|
@ -406,13 +406,6 @@ class GatewayWebsocket:
|
||||||
# link the state to the user
|
# link the state to the user
|
||||||
self.ext.state_manager.insert(self.state)
|
self.ext.state_manager.insert(self.state)
|
||||||
|
|
||||||
# update last_session
|
|
||||||
await self.ext.db.execute("""
|
|
||||||
UPDATE users
|
|
||||||
SET last_session = (now() at time zone 'utc')
|
|
||||||
WHERE id = $1
|
|
||||||
""", user_id)
|
|
||||||
|
|
||||||
await self.update_status(presence)
|
await self.update_status(presence)
|
||||||
await self.subscribe_all()
|
await self.subscribe_all()
|
||||||
await self.dispatch_ready()
|
await self.dispatch_ready()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue