Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
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())
Ejemplo n.º 3
0
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())
Ejemplo n.º 4
0
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())
Ejemplo n.º 5
0
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())
Ejemplo n.º 6
0
def logout():
    session.pop('user_id', None)
    session.pop('nickname')
    flash(u'You were signed out')
    return redirect(oid.get_next_url())
Ejemplo n.º 7
0
def login():
	if g.user is not None:
		return redirect(oid.get_next_url())
	return oid.try_login('http://steamcommunity.com/openid')
Ejemplo n.º 8
0
def logout():
	session.pop('user_id', None)
	return redirect(oid.get_next_url())
Ejemplo n.º 9
0
def logout():
    session.pop('user_id', None)
    session.pop('nickname')
    flash(u'You were signed out')
    return redirect(oid.get_next_url())