Skip to content

Commit

Permalink
Prune expired tokens before each request
Browse files Browse the repository at this point in the history
fixes 091labs#3
  • Loading branch information
Tom Leaman committed Apr 20, 2014
1 parent 14962a4 commit fb0f9f0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions uamhnach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

@app.before_request
def before_request():
# prune expired tokens
for token in models.Token.query.all():
if not token.is_valid():
db.session.delete(token)
db.session.commit()

# validate current one and set g.user
user = None
if 'X-Auth-Token' in request.headers:
auth_token_id = request.headers['X-Auth-Token']
Expand Down

0 comments on commit fb0f9f0

Please sign in to comment.