def load_anonymous_user(): """ Factory method for anonymous users which stores a user ID in the session. This is assigned to `login_manager.anonymous_user` in main.py. """ if 'anon_id' in session: au = AnonymousUser(session['anon_id']) else: aid = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)) session['anon_id'] = aid au = AnonymousUser(aid) set_user_id(au.get_id()) return au
def load_anonymous_user(): """ Factory method for anonymous users which stores a user ID in the session. This is assigned to `login_manager.anonymous_user` in main.py. """ if 'anon_id' in session: au = AnonymousUser(session['anon_id']) else: aid = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)) session['anon_id'] = aid au = AnonymousUser(aid) set_user_id(au.get_id()) return au
def load_user(userid): user = User.query.filter_by(id=userid).first() if user: set_user_id(user.email) return user
def load_user(userid): user = User.query.filter_by(id=userid).first() if user: set_user_id(user.email) return user