Updated flask-login to version 0.3.2

This commit is contained in:
Adam Shimali
2016-05-04 13:01:55 +01:00
parent d20228ea25
commit 09117e5eeb
11 changed files with 19 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ def choose_service():
@main.route("/services-or-dashboard")
def show_all_services_or_dashboard():
if not current_user.is_authenticated():
if not current_user.is_authenticated:
return redirect(url_for('.index'))
services = service_api_client.get_services({'user_id': current_user.id})['data']

View File

@@ -1,6 +1,6 @@
import markdown
import os
from flask import (render_template, url_for, redirect, Markup, current_app, abort)
from flask import (render_template, url_for, redirect, Markup)
from app.main import main
from flask_login import login_required
@@ -10,7 +10,7 @@ from mdx_gfm import GithubFlavoredMarkdownExtension
@main.route('/')
def index():
if current_user and current_user.is_authenticated():
if current_user and current_user.is_authenticated:
return redirect(url_for('main.choose_service'))
return render_template('views/signedout.html')

View File

@@ -24,7 +24,7 @@ def accept_invite(token):
invited_user = invite_api_client.check_token(token)
if not current_user.is_anonymous() and current_user.email_address != invited_user.email_address:
if not current_user.is_anonymous and current_user.email_address != invited_user.email_address:
message = Markup("""
Youre signed in as {}.
This invite is for another email address.

View File

@@ -26,7 +26,7 @@ from app import user_api_client
@main.route('/register', methods=['GET', 'POST'])
def register():
if current_user and current_user.is_authenticated():
if current_user and current_user.is_authenticated:
return redirect(url_for('main.choose_service'))
form = RegisterUserForm()

View File

@@ -29,7 +29,7 @@ from app.main.forms import LoginForm
@main.route('/sign-in', methods=(['GET', 'POST']))
def sign_in():
if current_user and current_user.is_authenticated():
if current_user and current_user.is_authenticated:
return redirect(url_for('main.choose_service'))
form = LoginForm()
@@ -52,9 +52,10 @@ def sign_in():
if user:
# Remember me login
if not login_fresh() and \
not current_user.is_anonymous() and \
not current_user.is_anonymous and \
current_user.id == user.id and \
user.is_active():
user.is_active:
confirm_login()
services = service_api_client.get_services({'user_id': str(user.id)}).get('data', [])
if (len(services) == 1):
@@ -63,7 +64,7 @@ def sign_in():
return redirect(url_for('main.choose_service'))
session['user_details'] = {"email": user.email_address, "id": user.id}
if user.is_active():
if user.is_active:
user_api_client.send_verify_code(user.id, 'sms', user.mobile_number)
if request.args.get('next'):
return redirect(url_for('.two_factor', next=request.args.get('next')))

View File

@@ -59,7 +59,7 @@ def verify_email(token):
if not user:
abort(404)
if user.is_active():
if user.is_active:
flash("That verification link has expired.")
return redirect(url_for('main.sign_in'))

View File

@@ -17,14 +17,16 @@ class User(UserMixin):
def get_id(self):
return self.id
@property
def is_active(self):
return self.state == 'active'
@property
def is_authenticated(self):
# To handle remember me token renewal
if not login_fresh():
return False
return super(User, self).is_authenticated()
return super(User, self).is_authenticated
@property
def id(self):

View File

@@ -39,7 +39,7 @@
<a href="#proposition-links" class="js-header-toggle menu">Menu</a>
<nav id="proposition-menu">
<ul id="proposition-links">
{% if current_user.is_authenticated() %}
{% if current_user.is_authenticated %}
<li>
<a href="{{ url_for('main.user_profile') }}">{{ current_user.name }}</a>
</li>