コード例 #1
0
def query_guild_visitor():
    guild_id = request.args.get('guild_id')
    if check_guild_existance(guild_id):
        if not guild_accepts_visitors(guild_id):
            abort(403)
        return process_query_guild(guild_id, True)
    abort(404)
コード例 #2
0
def create_authenticated_user():
    guild_id = request.form.get('guild_id')
    if session['unauthenticated']:
        response = jsonify(error=True)
        response.status_code = 401
        return response
    else:
        if not check_guild_existance(guild_id):
            abort(404)
        if not checkUserBanned(guild_id):
            if not check_user_in_guild(guild_id):
                add_member = discord_api.add_guild_member(
                    guild_id, session['user_id'],
                    session['user_keys']['access_token'])
                if not add_member["success"]:
                    response = jsonify(add_member)
                    response.status_code = 422
                    return response
            db_user = db.session.query(AuthenticatedUsers).filter(
                and_(AuthenticatedUsers.guild_id == guild_id,
                     AuthenticatedUsers.client_id ==
                     session['user_id'])).first()
            if not db_user:
                db_user = AuthenticatedUsers(guild_id, session['user_id'])
                db.session.add(db_user)
            status = update_user_status(guild_id, session['username'])
            return jsonify(status=status)
        else:
            status = {'banned': True}
            response = jsonify(status=status)
            response.status_code = 403
            return response
コード例 #3
0
ファイル: api.py プロジェクト: strelokhalfer/Titan
def change_unauthenticated_username():
    username = request.form['username']
    guild_id = request.form['guild_id']
    ip_address = get_client_ipaddr()
    username = username.strip()
    if len(username) < 2 or len(username) > 32:
        abort(406)
    if not all(x.isalnum() or x.isspace() or "-" == x or "_" == x
               for x in username):
        abort(406)
    if not check_guild_existance(guild_id):
        abort(404)
    if not guild_query_unauth_users_bool(guild_id):
        abort(401)
    if not checkUserBanned(guild_id, ip_address):
        if 'user_keys' not in session or guild_id not in session[
                'user_keys'] or not session['unauthenticated']:
            abort(424)
        session['username'] = username
        if 'user_id' not in session or len(str(session["user_id"])) > 4:
            session['user_id'] = random.randint(0, 9999)
        user = UnauthenticatedUsers(guild_id, username, session['user_id'],
                                    ip_address)
        db.session.add(user)
        db.session.commit()
        key = user.user_key
        session['user_keys'][guild_id] = key
        status = update_user_status(guild_id, username, key)
        return jsonify(status=status)
    else:
        status = {'banned': True}
        response = jsonify(status=status)
        response.status_code = 403
        return response
コード例 #4
0
def query_guild():
    guild_id = request.args.get('guild_id')
    if check_guild_existance(guild_id):
        if check_user_in_guild(guild_id):
            return process_query_guild(guild_id)
        abort(403)
    abort(404)
コード例 #5
0
def guild_embed(guild_id):
    if check_guild_existance(guild_id):
        guild = redisqueue.get_guild(guild_id)
        dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first()
        if not dbguild:
            abort(404)
        guild_dict = {
            "id": guild["id"],
            "name": guild["name"],
            "unauth_users": dbguild.unauth_users,
            "icon": guild["icon"],
            "invite_link": dbguild.invite_link,
            "invite_domain": parse_url_domain(dbguild.invite_link),
            "post_timeout": dbguild.post_timeout,
        }
        customcss = get_custom_css()
        return render_template("embed.html.j2",
            disabled=guild_id in list_disabled_guilds(),
            login_greeting=get_logingreeting(),
            guild_id=guild_id,
            guild=guild_dict,
            generate_guild_icon=generate_guild_icon_url,
            unauth_enabled=guild_query_unauth_users_bool(guild_id),
            visitors_enabled=guild_accepts_visitors(guild_id),
            unauth_captcha_enabled=guild_unauthcaptcha_enabled(guild_id),
            client_id=config['client-id'],
            recaptcha_site_key=config["recaptcha-site-key"],
            css=customcss,
            cssvariables=parse_css_variable(customcss),
            same_target=request.args.get("sametarget", False) == "true",
            userscalable=request.args.get("userscalable", "True").lower().startswith("t"),
            fixed_sidenav=request.args.get("fixedsidenav", "False").lower().startswith("t"),
            is_peak=is_peak(guild_id)
        )
    abort(404)
コード例 #6
0
def guild_embed(guild_id):
    if check_guild_existance(guild_id):
        guild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first()
        guild_dict = {
            "id": guild.guild_id,
            "name": guild.name,
            "unauth_users": guild.unauth_users,
            "icon": guild.icon,
            "discordio": guild.discordio,
        }
        customcss = get_custom_css()
        return render_template("embed.html.j2",
            login_greeting=get_logingreeting(),
            guild_id=guild_id,
            guild=guild_dict,
            generate_guild_icon=generate_guild_icon_url,
            unauth_enabled=guild_query_unauth_users_bool(guild_id),
            visitors_enabled=guild_accepts_visitors(guild_id),
            unauth_captcha_enabled=guild_unauthcaptcha_enabled(guild_id),
            client_id=config['client-id'],
            recaptcha_site_key=config["recaptcha-site-key"],
            css=customcss,
            cssvariables=parse_css_variable(customcss),
            same_target=request.args.get("sametarget", False) == "true"
        )
    abort(404)
コード例 #7
0
ファイル: api.py プロジェクト: jay121-git/Titan
def server_members_visitor():
    guild_id = request.args.get("guild_id", None)
    if not check_guild_existance(guild_id):
        abort(404)
    if not guild_accepts_visitors(guild_id):
        abort(403)
    members = query_server_members(guild_id)
    return jsonify(members)
コード例 #8
0
ファイル: api.py プロジェクト: jay121-git/Titan
def server_members():
    guild_id = request.args.get("guild_id", None)
    if not check_guild_existance(guild_id):
        abort(404)
    if not check_user_in_guild(guild_id):
        abort(403)
    members = query_server_members(guild_id)
    return jsonify(members)
コード例 #9
0
ファイル: api.py プロジェクト: jay121-git/Titan
def change_unauthenticated_username():
    username = request.form['username']
    guild_id = request.form['guild_id']
    ip_address = get_client_ipaddr()
    username = username.strip()
    if len(username) < 2 or len(username) > 32:
        abort(406)
    if not all(x.isalnum() or x.isspace() or "-" == x or "_" == x
               for x in username):
        abort(406)
    if not check_guild_existance(guild_id):
        abort(404)
    if not guild_query_unauth_users_bool(guild_id):
        abort(401)
    final_response = None
    if not checkUserBanned(guild_id, ip_address):
        if 'user_keys' not in session or guild_id not in session[
                'user_keys'] or not session['unauthenticated']:
            abort(424)
        emitmsg = {
            "unauthenticated": True,
            "username": session["username"],
            "discriminator": session["user_id"]
        }
        session['username'] = username
        if 'user_id' not in session or len(str(session["user_id"])) > 4:
            session['user_id'] = random.randint(0, 9999)
        user = UnauthenticatedUsers(guild_id, username, session['user_id'],
                                    ip_address)
        db.session.add(user)
        key = user.user_key
        session['user_keys'][guild_id] = key
        status = update_user_status(guild_id, username, key)
        emit("embed_user_disconnect",
             emitmsg,
             room="GUILD_" + guild_id,
             namespace="/gateway")
        final_response = jsonify(status=status)
    else:
        status = {'banned': True}
        response = jsonify(status=status)
        response.status_code = 403
        final_response = response
    db.session.commit()
    return final_response
コード例 #10
0
ファイル: api.py プロジェクト: jay121-git/Titan
def create_unauthenticated_user():
    session['unauthenticated'] = True
    username = request.form['username']
    guild_id = request.form['guild_id']
    ip_address = get_client_ipaddr()
    username = username.strip()
    if len(username) < 2 or len(username) > 32:
        abort(406)
    if not all(x.isalnum() or x.isspace() or "-" == x or "_" == x
               for x in username):
        abort(406)
    if not check_guild_existance(guild_id):
        abort(404)
    if not guild_query_unauth_users_bool(guild_id):
        abort(401)
    if guild_unauthcaptcha_enabled(guild_id):
        captcha_response = request.form['captcha_response']
        if not verify_captcha_request(captcha_response, request.remote_addr):
            abort(412)
    final_response = None
    if not checkUserBanned(guild_id, ip_address):
        session['username'] = username
        if 'user_id' not in session or len(str(session["user_id"])) > 4:
            session['user_id'] = random.randint(0, 9999)
        user = UnauthenticatedUsers(guild_id, username, session['user_id'],
                                    ip_address)
        db.session.add(user)
        key = user.user_key
        if 'user_keys' not in session:
            session['user_keys'] = {guild_id: key}
        else:
            session['user_keys'][guild_id] = key
        session.permanent = False
        status = update_user_status(guild_id, username, key)
        final_response = jsonify(status=status)
    else:
        status = {'banned': True}
        response = jsonify(status=status)
        response.status_code = 403
        final_response = response
    db.session.commit()
    return final_response
コード例 #11
0
def guild_embed(guild_id):
    if check_guild_existance(guild_id):
        guild = db.session.query(Guilds).filter(
            Guilds.guild_id == guild_id).first()
        guild_dict = {
            "id": guild.guild_id,
            "name": guild.name,
            "unauth_users": guild.unauth_users,
            "icon": guild.icon,
            "discordio": guild.discordio,
        }
        return render_template(
            "embed.html.j2",
            login_greeting=get_logingreeting(),
            guild_id=guild_id,
            guild=guild_dict,
            generate_guild_icon=generate_guild_icon_url,
            unauth_enabled=guild_query_unauth_users_bool(guild_id),
            visitors_enabled=guild_accepts_visitors(guild_id),
            client_id=config['client-id'],
            css=get_custom_css())
    abort(404)