Caching Flask-Login user_loader
问题 I had this. @login_manager.user_loader def load_user(id=None): return User.query.get(id) It was working fine until I introduced Flask-Principal. @identity_loaded.connect_via(app) def on_identity_loaded(sender, identity): # Set the identity user object identity.user = current_user # return if hasattr(current_user, 'id'): identity.provides.add(UserNeed(current_user.id)) # Assuming the User model has a list of roles, update the # identity with the roles that the user provides if hasattr(current