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()])
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()])
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")
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')
def logout(): session.pop('userid', None) return redirect(oid.get_next_url())