Skip to content

Commit

Permalink
Destroy token implemented for relational
Browse files Browse the repository at this point in the history
Cleaned code for graphdb
see pdonorio/restangulask#23
  • Loading branch information
Mattia D'Antonio committed Jun 15, 2016
1 parent 0551c6e commit 103f8bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 0 additions & 6 deletions restapi/resources/services/authentication/graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,7 @@ def invalidate_token(self, user=None, token=None):
def destroy_token(self, token_id):
try:
token = self._graph.Token.nodes.get(jti=token_id)

nodes = token.emitted_for.all()
if len(nodes) > 0:
token.emitted_for.disconnect(nodes[0])

token.delete()

return True

except self._graph.Token.DoesNotExist:
Expand Down
10 changes: 9 additions & 1 deletion restapi/resources/services/authentication/relationaldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,12 @@ def invalidate_token(self, user=None, token=None):
logger.warning("Could not invalidate token")

def destroy_token(self, token_id):
pass
token = self._db.Token.query.filter_by(jti=token_id).first()

if token is None:
return False

token.emitted_for = None # required?
self._db.session.delete(token)
self._db.session.commit()
return True

0 comments on commit 103f8bf

Please sign in to comment.