def login(): if session.get('user_id'): flash("You've logged in!") return redirect(oid.get_next_url()) if request.method == 'POST': openid = request.form.get('openid') if openid: return oid.try_login(openid, ask_for=['email', 'nickname', 'fullname']) return render_template('login.html', next=oid.get_next_url(), error=oid.fetch_error())
def create_or_login(resp): user = User.query.filter_by(google_account=resp.email).first() if user is None: user = User(nickname=resp.nickname or resp.fullname, google_account=resp.email, openid=resp.identity_url) if user.register(): flash(u"You've successfully registered and signed in!") else: flash(u'Register failed!') return redirect(oid.get_next_url()) else: flash("You've successfully logged in!") session['user_id'] = user.id g.user = user return redirect(oid.get_next_url())
def create_or_login(resp): match = _steam_id_re.search(resp.identity_url) steam_id = match.group(1) if Ban.query.get(steam_id) is not None: flash('Your SteamID is banned.') return redirect(url_for('index')) g.user = User.get_or_create(steam_id) steamdata = get_steam_userinfo(g.user.steam_id) g.user.nickname = steamdata['personaname'] db.session.commit() session['user_id'] = g.user.id flash('You are logged in as %s' % g.user.nickname) return redirect(oid.get_next_url())
def logout(): session.pop('user_id', None) session.pop('nickname') flash(u'You were signed out') return redirect(oid.get_next_url())
def login(): if g.user is not None: return redirect(oid.get_next_url()) return oid.try_login('http://steamcommunity.com/openid')
def logout(): session.pop('user_id', None) return redirect(oid.get_next_url())