Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/server/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def after_request_execute(response):

@app.teardown_appcontext
def teardown_db(exception=None):
# drop reference to "user" (if it exists)
if "user" in g:
g.pop("user")

# close the db connection
db = g.pop("db", None)

Expand Down
7 changes: 6 additions & 1 deletion src/server/_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def require_api_key() -> bool:
def _get_current_user():
if "user" not in g:
api_key = resolve_auth_token()
g.user = User.find_user(api_key=api_key)
if api_key:
g.user = User.find_user(api_key=api_key)
else:
g.user = None
return g.user


Expand Down Expand Up @@ -122,6 +125,8 @@ def decorated_function(*args, **kwargs):


def update_key_last_time_used(user):
# TODO: reenable this once cc<-->aws latency issues are sorted out, or maybe do this call asynchronously
return
if user:
# update last usage for this user's api key to "now()"
r = redis.Redis(host=REDIS_HOST, password=REDIS_PASSWORD)
Expand Down