예제 #1
0
def login():
    if current_user.is_authenticated():
        return redirect(oid.get_next_url())

    if request.method == "POST":
        return oid.try_login(COMMON_PROVIDERS["google"], ask_for=["email"])

    return render_template("login.html", next=oid.get_next_url(), errors=[oid.fetch_error()])
예제 #2
0
def login():
    if g.user is not None:
        return redirect(oid.get_next_url())

    if request.method == 'POST':
        return oid.try_login(COMMON_PROVIDERS['google'], ask_for=['email'])

    return render_template('login.html',
                           next=oid.get_next_url(),
                           errors=[oid.fetch_error()])
예제 #3
0
def after_login(resp):
    """OpenID callback. Called after the login was successful."""
    user = User.query.active().filter_by(email=resp.email).first()
    if user is not None:
        login_user(user)
        return redirect(oid.get_next_url())
    return render_template("unauthorized.html")
예제 #4
0
def after_login(resp):
    """OpenID callback. Called after the login was successful."""
    user = User.query.active().filter_by(email=resp.email).first()
    if user is not None:
        session['userid'] = user.id
        g.user = user
        return redirect(oid.get_next_url())
    session.pop('userid', None)
    return render_template('unauthorized.html')
예제 #5
0
def logout():
    session.pop('userid', None)
    return redirect(oid.get_next_url())