コード例 #1
0
ファイル: home.py プロジェクト: vlttnv/scrimfinder2
def login():
    """Log in via Steam OpenID

    """

    if g.user is not None:
        return redirect(oid.get_next_url())
    else:
        return oid.try_login('http://steamcommunity.com/openid')
コード例 #2
0
ファイル: home.py プロジェクト: vlttnv/scrimfinder2
def after_login(resp):
    """
    """
    steam_id_regex = re.compile('steamcommunity.com/openid/id/(.*?)$')
    steam_id = steam_id_regex.search(resp.identity_url).group(1)

    try:
        g.user = User.query.filter_by(steam_id=steam_id).one()
        user_info = get_user_info(g.user.steam_id)
        login_user(g.user)
        return redirect(oid.get_next_url())
    except NoResultFound:
        print "CREATIN USER"
        g.user = User()
        steam_data             = get_user_info(steam_id)
        g.user.steam_id        = steam_id
        g.user.nickname        = steam_data['personaname']
        g.user.avatar_url      = steam_data['avatar']
        g.user.avatar_url_full = steam_data['avatarfull']
        g.user.join_date       = dt.utcnow()
        db.session.add(g.user)
        db.session.commit()
        login_user(g.user)
        return redirect(url_for('home_bp.index'))