You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
383 B
Python
17 lines
383 B
Python
6 years ago
|
"""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
|