I graced the login_required method, but I am surprised that it does not execute at all, allowing anonymous users. Printing current_user inside the method returns this:
<flask_login.AnonymousUserMixin object at 0xb67dbd4c>
Are you supposed to reject users who return false in user.is_autheticated() ? What have I done wrong?
I have setup FL this way:
lm = LoginManager(app) lm.login_view = 'root'
in views.py:
@lm.user_loader def load_user(id): return User.query.get(int(id))
actual view:
@login_required @app.route("/messages") def messages(): print "current user", current_user return "hello world"
python flask
aitchnyu
source share