Example #1
0
def create_or_login(resp):
    id = steam_id_re.findall(resp.identity_url)[0]

    g.cursor.execute("SELECT id, active, ugroup FROM users WHERE steamid=%s", (id, ))
    user = g.cursor.fetchone()

    if user:
        if user.active:
            g.user = user.id
            g.group = user.ugroup
            g.cursor.execute("UPDATE users SET last_login=%s WHERE id=%s", (datetime.utcnow(), user.id))
        else:
            raise UserError("Account Disabled. Please contact support for more information")
    else:
        allowed = steam.getGroupMembers("emporiumbeta")
        if int(id) not in allowed:
            log.warning("User %s is not allowed in beta (%s)" % (id, allowed))
            raise UserError("Sorry, your not part of the beta! :(")

        if id in auto_admin_steamids:
            group = 'super'
        else:
            group = 'normal'
        g.user = create_user(id, group)
        g.group = group

    g.session["u"] = g.user
    return redirect(oid.get_next_url())
Example #2
0
    def test_create_user(self):
        uid = create_user(FAKE_STEAM_ID)
        self.assertGreaterEqual(uid, 1)

        with Cursor() as c:
            count = c.count("users")
            self.assertGreaterEqual(count, 1)

        self.assertRaises(IntegrityError, create_user, (FAKE_STEAM_ID, ))