"""Methods for app lifecycle (before/after request, ...)""" from flask import g, session from app.models import User def authenticate(): """read session to authenticate user. Stores user object in flask.g For use in before_request """ g.user = None if session.get('auth') is not None: user = User.query.get(session['auth']) g.user = user