Remove extra call to the DB for a user we already have

This commit is contained in:
Joseph Schorr 2015-05-07 17:17:05 -04:00
parent 729249f42b
commit 76bef38d71

View file

@ -33,10 +33,13 @@ def _load_user_from_cookie():
return None
logger.debug('Loading user from cookie: %s', current_user.get_id())
set_authenticated_user_deferred(current_user.get_id())
loaded = QuayDeferredPermissionUser.for_user(current_user.db_user())
identity_changed.send(app, identity=loaded)
return current_user.db_user()
db_user = current_user.db_user()
if db_user is not None:
set_authenticated_user(db_user)
loaded = QuayDeferredPermissionUser.for_user(db_user)
identity_changed.send(app, identity=loaded)
return db_user
return None