def login(): if g.user is not None: return redirect(oid.get_next_url()) providers = app.config['OPENID_PROVIDERS'] openid = None if request.method == 'GET' and 'provider' in request.args: openid = providers.get(request.args.get('provider')) elif request.method == 'POST': openid = request.form.get('openid') if openid: return oid.try_login(openid, ask_for=['email']) return render_template('login.html', next=oid.get_next_url(), error=oid.fetch_error())
def after_login(resp): session['openid'] = resp.identity_url user = User(openid=resp.identity_url) if not user.exists(): user.set(identity_url=resp.identity_url, email=resp.email) flash('Successfully signed in') g.user = user return redirect(oid.get_next_url())
def logout(): session.pop('openid', None) flash('You were signed out') return redirect(oid.get_next_url())