예제 #1
0
파일: index.py 프로젝트: KasaiDot/bangumi
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())
예제 #2
0
파일: index.py 프로젝트: ececleon/bangumi
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())
예제 #3
0
파일: index.py 프로젝트: KasaiDot/bangumi
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())
예제 #4
0
파일: index.py 프로젝트: ececleon/bangumi
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())
예제 #5
0
파일: routes.py 프로젝트: fparma/events
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())
예제 #6
0
파일: index.py 프로젝트: ececleon/bangumi
def logout():
    session.pop('user_id', None)
    session.pop('nickname')
    flash(u'You were signed out')
    return redirect(oid.get_next_url())
예제 #7
0
파일: routes.py 프로젝트: fparma/events
def login():
	if g.user is not None:
		return redirect(oid.get_next_url())
	return oid.try_login('http://steamcommunity.com/openid')
예제 #8
0
파일: routes.py 프로젝트: fparma/events
def logout():
	session.pop('user_id', None)
	return redirect(oid.get_next_url())
예제 #9
0
파일: index.py 프로젝트: KasaiDot/bangumi
def logout():
    session.pop('user_id', None)
    session.pop('nickname')
    flash(u'You were signed out')
    return redirect(oid.get_next_url())