I'm using Flask-Security to manage users, and I'm getting reports that users are logged-in successfully as themselves, but randomly when they load a page, it will show them logged as someone completely different. I'm not sure where I'm going wrong. What are possible ways this could happen?
I user a UserService to do some simple user management. I instantiate a user service before every request and pass in current_user.
@app.before_request def load_request_services(): g.user_service = UserService(user_datastore, application_service, email_service, ORGS, current_user)
Then, I get the current user in UserService from this method:
def current_user_get_info(self): return { 'user': self.current_user.email, 'first_name': self.current_user.first_name, 'last_name': self.current_user.last_name, 'phone_number': self.current_user.phone_number, }
this is called when this API request code is executed:
class CurrentUser(restful.Resource): def get(self): return json_response(g.user_service.current_user_get_info())