consolidate stale client_id check to AccessToken.find

This commit is contained in:
Min RK
2018-04-13 21:49:57 +02:00
parent bc75c71ca3
commit 1ac47d2bb0
3 changed files with 13 additions and 10 deletions

View File

@@ -457,6 +457,19 @@ class OAuthAccessToken(Hashed, Base):
prefix=self.prefix,
)
@classmethod
def find(cls, db, token):
orm_token = super().find(db, token)
if orm_token and not orm_token.client_id:
app_log.warning(
"Deleting stale oauth token for %s with no client",
orm_token.user and orm_token.user.name,
)
db.delete(orm_token)
db.commit()
return
return orm_token
class OAuthCode(Base):
__tablename__ = 'oauth_codes'