I found this in the Stormpath docs:
is_authenticated() (http://flask-stormpath.readthedocs.io/en/latest/api.html)
All users will always be authenticated, so this will always return True.
So is_authenticated does not seem to work as it does in flask-login. Do I have to do a workaround or is there a similar function already pre-buildt in this API?
---EDIT---
Thanks for the answer, but it still does not seem to work. What I am trying to do is this:
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>
app.py
@app.route('/navbar')
def navbar():
if user:
return render_template('navbar.html', result=user.given_name)
else:
return render_template('navbar.html')
And I get this error message:
AttributeError: 'AnonymousUserMixin' object has no attribute 'given_name'
I had this error as well. I used similar code as that provided above:
if user:
return render_template('index.html', given_name=user.given_name)
return render_template('index.html')
and would get the same error as in OP:
AttributeError: 'AnonymousUserMixin' object has no attribute 'given_name'
I fixed it by changing the code to:
if user.is_anonymous() == False:
return render_template('index.html', given_name=user.given_name)
return render_template('index.html')
It seems that the error was that the if statement for the user object always resolves as True because the user object is instantiated in some way when importing user from flask.ext.stormpath.