示例#1
0
def login():
    '''Redirects to the homepage if the user is logged in. Displays the login page if the user is not logged in.'''
    if (user.is_logged_in()):
        return redirect(url_for("home"))
    if 'msg' in request.args:
        flash('Please log in before following a politician', 'danger')
    return render_template("login.html")
示例#2
0
def settings():
    """Settings for users, shows list of all followed politicians and can unfollow."""
    if (user.is_logged_in()):
        for name in request.args:
            database.unfollow(session['id'], name)
        followed = []
        data = database.get_followed(session['id'])
        for row in data:
            followed.append(row[0])
        return render_template("settings.html",
                               listFollowed=followed,
                               s=session)
    else:
        flash("You must be logged in to see that page!", "danger")
        return redirect(url_for("home"))
示例#3
0
 def render(self, navbar: dict):
     if is_logged_in():
         return redirect('/profile')
     return super(Login, self).render(navbar=navbar)
示例#4
0
 def visible(self):
     return not is_logged_in()
示例#5
0
def before_request():
    if request.path.startswith('/static/'):
        return None
    elif request.path not in allow_anonymous and not is_logged_in():
        return redirect('login')
示例#6
0
def register():
    '''Display the register page.'''
    if (user.is_logged_in()):
        redirect(url_for("home"))
    return render_template("register.html", isLoggedIn=user.is_logged_in())