Fix bug where the database session sometimes wasn't closed

feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
parent 997d99e8ee
commit 1429f1259c
  1. 3
      auth_server.py

@ -38,10 +38,12 @@ class AuthProtocol(ServerProtocol):
token = session.query(AccountLinkToken).filter_by(token=connection_token).first() token = session.query(AccountLinkToken).filter_by(token=connection_token).first()
if not token: if not token:
self.close("You have connected with an invalid token!") self.close("You have connected with an invalid token!")
session.close()
return return
discord_account = session.query(DiscordAccount).filter_by(link_token_id=token.id).first() discord_account = session.query(DiscordAccount).filter_by(link_token_id=token.id).first()
if not discord_account: if not discord_account:
self.close("You have connected with an invalid token!") self.close("You have connected with an invalid token!")
session.close()
return return
if datetime.utcnow() < token.expiry: if datetime.utcnow() < token.expiry:
# Check if they already have a linked account and are re-linking # Check if they already have a linked account and are re-linking
@ -66,6 +68,7 @@ class AuthProtocol(ServerProtocol):
except Exception as e: except Exception as e:
self.logger.error(e) self.logger.error(e)
session.close()
# Kick the player. # Kick the player.

Loading…
Cancel
Save