Flask login 是否有一个简单的';是经过认证的';Stormpath中的解决方案?

Flask login 是否有一个简单的';是经过认证的';Stormpath中的解决方案?,flask-login,stormpath,Flask Login,Stormpath,我在Stormpath文档中找到了以下内容: is_authenticated() (http://flask-stormpath.readthedocs.io/en/latest/api.html) All users will always be authenticated, so this will always return True. 因此,is_authenticated似乎不像flask登录中那样工作。我是否必须做一个变通方法,或者在这个API中是否已经预构建了类似的函数 ---

我在Stormpath文档中找到了以下内容:

is_authenticated() (http://flask-stormpath.readthedocs.io/en/latest/api.html)
All users will always be authenticated, so this will always return True.
因此,is_authenticated似乎不像flask登录中那样工作。我是否必须做一个变通方法,或者在这个API中是否已经预构建了类似的函数

---编辑---

谢谢你的回答,但它似乎仍然不起作用。我想做的是:

from flask_stormpath import user

def my_view():
    if user:
        # there is a user who is authenticated!
    else:
        # nobody has authenticated :(
navbar.html

<div class="navbar-right">
    {% if user %}
    <p class="navbar-text">Signed in as <a href="#" class="navbar-link">{{ result }}</a></p>
    {% else %}
    <button id="registerbtn" type="button" class="btn btn-default navbar-btn">Sign up</button>
    {% endif %}
</div>
我得到这个错误信息:

AttributeError: 'AnonymousUserMixin' object has no attribute 'given_name'

我是这个图书馆的作者。确实有一种方法可以检查用户是否经过身份验证——您找到的代码实际上是内部Flask登录API的一部分,并不用于公共消费

您要做的是:

from flask_stormpath import user

def my_view():
    if user:
        # there is a user who is authenticated!
    else:
        # nobody has authenticated :(

那会得到你想要的=)

我也有这个错误。我使用了与上述类似的代码:

if user:
     return render_template('index.html', given_name=user.given_name)
return render_template('index.html')
并将得到与OP中相同的错误:

AttributeError: 'AnonymousUserMixin' object has no attribute 'given_name'
我将代码更改为:

if user.is_anonymous() == False:
    return render_template('index.html', given_name=user.given_name)
return render_template('index.html')

似乎错误在于用户对象的if语句总是解析为True,因为从flask.ext.stormpath导入用户时,用户对象以某种方式实例化

似乎仍然不起作用,我更新了我的问题-也许你可以再次帮助我。:)除了Flask Stormpath,您是否正在使用其他插件?查看您更新的问题,您似乎有其他内容覆盖了
用户
对象。不,在这个应用程序中,除了Flask Stormpath之外,没有其他插件。