Esempio n. 1
0
def load_current_user():
    g.db = engine.connect()
    g.user = User.query.filter_by(id=session['user_id']).first() if 'user_id' in session else None
    g.company = Company.query.filter_by(id=g.user.company_id).first() if g.user else None
Esempio n. 2
0
def load_current_user():
    g.db = engine.connect()
    #g.user = User.query.filter_by(id=session['user_id']).first() if 'user_id' in session else None
    g.user = g.db.execute(text("SELECT * FROM users WHERE id=:id"), id=session['user_id']).first() if 'user_id' in session else None
    g.company = Company.query.filter_by(id=g.user.company_id).first() if g.user else None