TypeError: 'bool' object is not callable g.user.is_authenticated() [duplicate]
Try replace if g.user.is_authenticated():
to if g.user.is_authenticated:
like this:
@app.before_requestdef before_request(): g.user = current_user if g.user.is_authenticated: g.search_form = None
From the document:
is_authenticated
Returns True if the user is authenticated, i.e. they have provided valid credentials. (Only authenticated users will fulfill the criteria of login_required.)
As the document said, is_authenticated is a boolean(True
or False
).
And however, it was a function in the past, but it has been changed to boolean at version 3.0:
BREAKING:
Theis_authenticated
,is_active
, andis_anonymous
members of the user class are now properties, not methods. Applications should update their user classes accordingly.
This is because is_authenticated
is not a function but a mere boolean. Try the following instead:
@app.before_requestdef before_request(): g.user = current_user if g.user.is_authenticated: g.search_form = None