Skip to content

Commit

Permalink
Doh! SQLAlchemy <grumble>, <grumble>, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
portante committed Feb 14, 2023
1 parent dfb770b commit 129e773
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/pbench/server/database/models/auth_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

from pbench.server.database.database import Database

# Convenient shortened name
dbs = Database.db_session


class AuthToken(Database.Base):
"""Model for storing the active auth tokens associated with a user."""
Expand Down Expand Up @@ -35,6 +32,7 @@ def query(auth_token: str) -> Optional["AuthToken"]:
An AuthToken object if found, otherwise None
"""
# We currently only query token database with the given token.
dbs = Database.db_session
return dbs.query(AuthToken).filter_by(auth_token=auth_token).first()

@staticmethod
Expand All @@ -44,6 +42,7 @@ def delete(auth_token: str):
Args:
auth_token : the auth token to delete
"""
dbs = Database.db_session
try:
dbs.query(AuthToken).filter_by(auth_token=auth_token).delete()
dbs.commit()
Expand Down

0 comments on commit 129e773

Please sign in to comment.