Skip to content
Advertisement

How to get current user when implementing Python Flask-Security?

I am using Flask-Security to set up user authentication for my app but I am struggling with getting the email address or ID of the currently logged in user so I can query a table with that particular users details. I’ve just using the standard code.

Another question here suggested the following but it didn’t work:

JavaScript

Standard code:

JavaScript

Advertisement

Answer

You can use flask_login.current_user object. Its class will be what you configured Flask-Security to use to handle your users management, e.g. User for code you included.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement