Exemplo n.º 1
0
def changepass(steamid):
    if request.method == "POST":
        if current_user.has_role("admin") or current_user.steamid == steamid:
            if request.form["password"] == "" or request.form["password_confirm"] == "":
                flash(f"Password cannot be blank", "error")
                return redirect(url_for("webui.changepass", steamid=steamid))
            elif len(request.form["password"]) < 7:
                flash(f"Password must be at least 7 characters long", "error")
                return redirect(url_for("webui.changepass", steamid=steamid))
            elif request.form["password"] != request.form["password_confirm"]:
                flash(f"Passwords do not match", "error")
                return redirect(url_for("webui.changepass", steamid=steamid))
            elif request.form["password"] == request.form["password_confirm"]:
                dbupdate(
                    "UPDATE web_users SET password = '******' WHERE steamid = '%s'"
                    % (hash_password(request.form["password"]), steamid)
                )
                flash(f"Password changed", "success")
                webuser = User.query.filter_by(steamid=steamid).first()
                return render_template(
                    "webinfo.html",
                    webuser=webuser,
                    playerinfo=getplayer(steamid=steamid, fmt="dict"),
                )
    if current_user.has_role("admin") or current_user.steamid == steamid:
        return render_template(
            "changepass.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
        )
Exemplo n.º 2
0
def messages():
    if request.method == "POST":
        if (
            request.form["player"]
            == getplayer(steamid=current_user.steamid, fmt="dict")["playername"]
        ):
            flash(f"You cannot send a message to yourself", "error")
        elif request.form["message"] == "":
            flash(f"You cannot send a blank message", "error")
        elif not validatelastsent(current_user.steamid):
            flash(f"You must wait before sending another message", "error")
        elif not validatenumsent(current_user.steamid):
            flash(
                f"You cannot send more then 5 messages that haven't been read yet",
                "error",
            )
        else:
            sendmessage(
                current_user.steamid,
                getplayer(playername=request.form["player"], fmt="dict")["steamid"],
                request.form["message"],
            )
            flash(f'Message Sent to {request.form["player"].title()}', "info")
        return render_template("messages.html", players=getplayernames())
    return render_template("messages.html", players=getplayernames())
Exemplo n.º 3
0
def _bantoggle(steamid):
    if isplayerbanned(steamid=steamid):
        banunbanplayer(steamid=steamid, ban=False)
        flash("Player has been Un-Banned", "success")
        return render_template(
            "playerinfo.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
        )
    else:
        banunbanplayer(steamid=steamid, ban=True)
        flash("Player has been BANNED!", "error")
        return render_template(
            "playerinfo.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
        )
Exemplo n.º 4
0
def playerinfo(steamid):
    if request.method == "POST":
        serverchat(
            request.form["message"],
            whosent=steamid,
            inst=getplayer(steamid=steamid, fmt="dict")["server"],
            private=True,
        )
        flash(f"Message Sent", "info")
        return redirect(url_for("webui.playerinfo", steamid=steamid))
    return render_template(
        "playerinfo.html",
        playerinfo=getplayer(steamid=steamid, fmt="dict"),
        tribes=getplayertribes(steamid),
    )
Exemplo n.º 5
0
def webcreate(steamid):
    if request.method == "POST":
        user_datastore.create_user(
            email=request.form["email"],
            password=hash_password(request.form["password"]),
            steamid=request.form["steamid"],
            timezone=request.form["timezone"],
        )
        db.session.commit()
        flash(f"Web User Created", "info")
        webuser = User.query.filter_by(steamid=steamid).first()
        return render_template(
            "webinfo.html",
            webuser=webuser,
            playerinfo=getplayer(steamid=steamid, fmt="dict"),
        )
    return render_template(
        "webcreate.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
    )
Exemplo n.º 6
0
def webinfo(steamid):
    if request.method == "POST":
        if request.form["btype"] == "Update Settings":
            User.query.filter_by(steamid=steamid).update(
                dict(timezone=request.form["timezone"])
            )
            db.session.commit()
            flash(f"Settings Updated", "success")
        elif request.form["btype"] == "Toggle Active":
            user_datastore.activate_user(
                User.query.filter_by(email=request.form["email"]).first()
            )
            db.session.commit()
            flash(f"Toggled Account Access", "success")
        elif request.form["btype"] == "Change Password":
            return redirect(url_for("webui.changepass", steamid=steamid))
        webuser = User.query.filter_by(steamid=steamid).first()
        return render_template(
            "webinfo.html",
            webuser=webuser,
            playerinfo=getplayer(steamid=steamid, fmt="dict"),
        )
    webuser = User.query.filter_by(steamid=steamid).first()
    if not hasattr(webuser, "email"):
        flash(f"Player does not have a web account", "warning")
        return render_template(
            "playerinfo.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
        )
    else:
        if current_user.has_role("admin") or current_user.steamid == steamid:
            return render_template(
                "webinfo.html",
                webuser=webuser,
                playerinfo=getplayer(steamid=steamid, fmt="dict"),
            )
        else:
            flash(f"Invalid Access", "error")
            return render_template(
                "playerinfo.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
            )
Exemplo n.º 7
0
def result2():
    if request.method == "POST":
        return render_template(
            "playerinfo.html",
            playerinfo=getplayer(discordid=request.form["player"].lower(), fmt="dict"),
        )
Exemplo n.º 8
0
def result():
    if request.method == "POST":
        return render_template(
            "playerinfo.html",
            playerinfo=getplayer(steamid=request.form["player"], fmt="dict"),
        )
Exemplo n.º 9
0
def _kickplayer(steamid, instance):
    kickplayer(instance, steamid)
    flash("Kicking player from %s" % (instance,), "info")
    return render_template(
        "playerinfo.html", playerinfo=getplayer(steamid=steamid, fmt="dict")
    )
Exemplo n.º 10
0
def test_getplayer():
    assert players.getplayer(99999999999999999) is None
    assert players.getplayer(76561198388849736) is not None
    assert players.getplayer(76561198388849736)[1] == "rykker"