Using flask_login session with jinja2 templates

2019-04-18 03:00发布

I have simple jinja2 template with registration/login links, I should hide them when user logged in, I also use flask_login module for this stuff.

Question is: How should I identify is user logged in in jinja2 templates?

1条回答
SAY GOODBYE
2楼-- · 2019-04-18 03:37

Flask-Login adds the current_user variable to your templates:

{% if current_user.is_authenticated %}
    ...
{% else %}
    ...
{% endif %}

They mention this briefly in the documentation.

查看更多
登录 后发表回答