Adapted to support changes in Flask-Login 0.3
This commit is contained in:
parent
5e9cc831e8
commit
751a8aefe5
|
@ -50,12 +50,15 @@ class User(db.Model):
|
|||
version += 1
|
||||
return new_nickname
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_active(self):
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_anonymous(self):
|
||||
return False
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@
|
|||
<a class="brand" href="{{ url_for('index') }}">microblog</a>
|
||||
<ul class="nav">
|
||||
<li><a href="{{ url_for('index') }}">{{ _('Home') }}</a></li>
|
||||
{% if g.user.is_authenticated() %}
|
||||
{% if g.user.is_authenticated %}
|
||||
<li><a href="{{ url_for('user', nickname=g.user.nickname) }}">{{ _('Your Profile') }}</a></li>
|
||||
<li><a href="{{ url_for('logout') }}">{{ _('Logout') }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="nav-collapse collapse">
|
||||
{% if g.user.is_authenticated() %}
|
||||
{% if g.user.is_authenticated %}
|
||||
<form class="navbar-search pull-right" action="{{ url_for('search') }}" method="post" name="search">{{ g.search_form.hidden_tag() }}{{ g.search_form.search(size=20, placeholder=_('Search'), class="search-query")}}</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -28,7 +28,7 @@ def get_locale():
|
|||
@app.before_request
|
||||
def before_request():
|
||||
g.user = current_user
|
||||
if g.user.is_authenticated():
|
||||
if g.user.is_authenticated:
|
||||
g.user.last_seen = datetime.utcnow()
|
||||
db.session.add(g.user)
|
||||
db.session.commit()
|
||||
|
@ -84,7 +84,7 @@ def index(page=1):
|
|||
@app.route('/login', methods=['GET', 'POST'])
|
||||
@oid.loginhandler
|
||||
def login():
|
||||
if g.user is not None and g.user.is_authenticated():
|
||||
if g.user is not None and g.user.is_authenticated:
|
||||
return redirect(url_for('index'))
|
||||
form = LoginForm()
|
||||
if form.validate_on_submit():
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Babel==1.3
|
||||
Flask==0.10.1
|
||||
Flask-Babel==0.9
|
||||
Flask-Login==0.2.11
|
||||
Flask-Login==0.3.0
|
||||
Flask-Mail==0.9.0
|
||||
Flask-OpenID==1.2.1
|
||||
Flask-SQLAlchemy==2.0
|
||||
|
|
6
tests.py
6
tests.py
|
@ -37,9 +37,9 @@ class TestCase(unittest.TestCase):
|
|||
u = User(nickname='john', email='john@example.com')
|
||||
db.session.add(u)
|
||||
db.session.commit()
|
||||
assert u.is_authenticated() is True
|
||||
assert u.is_active() is True
|
||||
assert u.is_anonymous() is False
|
||||
assert u.is_authenticated is True
|
||||
assert u.is_active is True
|
||||
assert u.is_anonymous is False
|
||||
assert u.id == int(u.get_id())
|
||||
|
||||
def test_avatar(self):
|
||||
|
|
Loading…
Reference in New Issue