Get information about current logged in user?

时间:2016-07-11 21:23:49

标签: flask-sqlalchemy

I'm making a flask application in which there are three permissions of a user model. I want to use data about the current user who is logged in in order to restrict or grant access to certain pages. I'm unsure how to load the data about the current user in session into a variable to get the permission level from the actual user who is logged in. Any suggestions? I was thinking I could use g

1 个答案:

答案 0 :(得分:0)

我建议您查看使用Flask-Login,它为Flask提供用户会话管理。然后,您可以扩展您的用户模型以存储您需要的任何额外信息,Flask-Login以current_user的形式为您提供可从您的请求处理程序和模板访问的代理对象。