mirror of
https://github.com/wassname/flask-security.git
synced 2026-09-09 11:22:35 +08:00
Changing is_authenticated from function to property & updating Flask-Login>=0.3.0
This commit is contained in:
@@ -57,7 +57,7 @@ def _check_token():
|
|||||||
|
|
||||||
user = _security.login_manager.token_callback(token)
|
user = _security.login_manager.token_callback(token)
|
||||||
|
|
||||||
if user and user.is_authenticated():
|
if user and user.is_authenticated:
|
||||||
app = current_app._get_current_object()
|
app = current_app._get_current_object()
|
||||||
_request_ctx_stack.top.user = user
|
_request_ctx_stack.top.user = user
|
||||||
identity_changed.send(app, identity=Identity(user.id))
|
identity_changed.send(app, identity=Identity(user.id))
|
||||||
@@ -138,7 +138,7 @@ def auth_required(*auth_methods):
|
|||||||
login_mechanisms = {
|
login_mechanisms = {
|
||||||
'token': lambda: _check_token(),
|
'token': lambda: _check_token(),
|
||||||
'basic': lambda: _check_http_auth(),
|
'basic': lambda: _check_http_auth(),
|
||||||
'session': lambda: current_user.is_authenticated()
|
'session': lambda: current_user.is_authenticated
|
||||||
}
|
}
|
||||||
|
|
||||||
def wrapper(fn):
|
def wrapper(fn):
|
||||||
@@ -220,7 +220,7 @@ def roles_accepted(*roles):
|
|||||||
def anonymous_user_required(f):
|
def anonymous_user_required(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
if current_user.is_authenticated():
|
if current_user.is_authenticated:
|
||||||
return redirect(utils.get_url(_security.post_login_view))
|
return redirect(utils.get_url(_security.post_login_view))
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ def login():
|
|||||||
def logout():
|
def logout():
|
||||||
"""View function which handles a logout request."""
|
"""View function which handles a logout request."""
|
||||||
|
|
||||||
if current_user.is_authenticated():
|
if current_user.is_authenticated:
|
||||||
logout_user()
|
logout_user()
|
||||||
|
|
||||||
return redirect(request.args.get('next', None) or
|
return redirect(request.args.get('next', None) or
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Flask>=0.9
|
Flask>=0.9
|
||||||
Flask-Login>=0.1.3
|
Flask-Login>=0.3.0
|
||||||
Flask-Mail>=0.7.3
|
Flask-Mail>=0.7.3
|
||||||
Flask-Principal>=0.3.3
|
Flask-Principal>=0.3.3
|
||||||
Flask-WTF>=0.8
|
Flask-WTF>=0.8
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{%- if current_user.is_authenticated() -%}
|
{%- if current_user.is_authenticated -%}
|
||||||
<p>Hello {{ current_user.email }}</p>
|
<p>Hello {{ current_user.email }}</p>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
<ul>
|
<ul>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<li><a href="{{ url_for('admin_or_editor') }}">Admin or Editor</a></li>
|
<li><a href="{{ url_for('admin_or_editor') }}">Admin or Editor</a></li>
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
<li>
|
<li>
|
||||||
{%- if current_user.is_authenticated() -%}
|
{%- if current_user.is_authenticated -%}
|
||||||
<a href="{{ url_for('security.logout') }}">Log out</a>
|
<a href="{{ url_for('security.logout') }}">Log out</a>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<a href="{{ url_for('security.login') }}">Log in</a>
|
<a href="{{ url_for('security.login') }}">Log in</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user