Ejemplo n.º 1
0
def get_response():
    post_form = krait.request.get_post_form()
    username = post_form.get("username")
    password = post_form.get("password")

    if username is None or password is None:
        return krait.Response(
            "HTTP/1.1", 400, {},
            "<html><body><h1>400 Bad Request</h1></body></html>")

    redirect_url = "/login_fail"
    fail = False
    try:
        db_conn = db_ops.get_connection()
        cursor = db_conn.cursor()
        result = cursor.callfunc("user_ops.checkSaltedPassword",
                                 cursor.var(cx_Oracle.NUMBER),
                                 [username, password])
        db_conn.commit()
    except cx_Oracle.DatabaseError, exception:
        error_messages = [
            "Error checking DB for username {}: {}".format(
                username, exception.args[0])
        ]
        redirect_url += "?errors=" + urllib.quote_plus(
            json.dumps(error_messages))
        fail = True
        result = 0
Ejemplo n.º 2
0
def get_response():
	# insert logic using request.query["..."] (campuri setate din form)
	post_form = krait.request.get_post_form()

	username = post_form.get("username")
	password = post_form.get("password")
	
	if username is None or password is None:		
		return krait.Response("HTTP/1.1", 400, {}, "<html><body><h1>400 Bad Request</h1></body></html>");
	
	redirect_url = "/admin/user_console"
	try:
		db_conn = db_ops.get_connection();
		cursor = db_conn.cursor()
		cursor.callproc("user_ops.addPlayer", [username, password])
		db_conn.commit()
	except cx_Oracle.DatabaseError, exception:
		error_messages = ["Could not add user {}: {}".format(username, exception.args[0].message)]
		redirect_url += "?errors=" + urllib.quote_plus(json.dumps(error_messages))
Ejemplo n.º 3
0
def get_response():
    user_id = krait.request.get_post_form().get("id")
    if user_id is None:
        return krait.Response(
            "HTTP/1.1", 400, [],
            "<html><body><h1>400 Bad Request</h1></body></html>")

    redirect_url = "/admin/user_console"
    try:
        db_conn = db_ops.get_connection()
        cursor = db_conn.cursor()
        cursor.callproc("user_ops.deletePlayer", [user_id])
        db_conn.commit()
    except cx_Oracle.DatabaseError, exception:
        error_messages = [
            "Could not delete user {}: {}".format(user_id,
                                                  exception.args[0].message)
        ]
        redirect_url += "?errors=" + urllib.quote_plus(
            json.dumps(error_messages))
Ejemplo n.º 4
0
def get_response():
	# update logic using request.query["..."] (campuri setate din form)
	post_form = krait.request.get_post_form()
	id = post_form.get("id")
	username = post_form.get("username")
	password = post_form.get("password")
	loadout = None
	in_match = None
	mmr = post_form.get("mmr")
	level = post_form.get("level")

	if id is None:
		return krait.Response("HTTP/1.1", 400, {}, "<html><body><h1>400 Bad Request</h1></body></html>");

	redirect_url = "/admin/user_console"
	try:
		db_conn = db_ops.get_connection()
		cursor = db_conn.cursor()
		cursor.callproc("user_ops.updatePlayer", [id, username, password, loadout, in_match, mmr, level])
		db_conn.commit()
	except cx_Oracle.DatabaseError, exception:
		error_messages = ["Could not update user {}: {}".format(username, exception.args[0].message)]
		redirect_url += "?errors=" + urllib.quote_plus(json.dumps(error_messages))
Ejemplo n.º 5
0
import cx_Oracle
import urllib
import json
import krait
from db_access import db_ops
import krait


def get_response():
    user_id = krait.request.get_post_form().get("id")
    if user_id is None:
        return krait.Response(
            "HTTP/1.1", 400, [],
            "<html><body><h1>400 Bad Request</h1></body></html>")

    redirect_url = "/admin/user_console"
    try:
        db_conn = db_ops.get_connection()
        cursor = db_conn.cursor()
        cursor.callproc("user_ops.deletePlayer", [user_id])
        db_conn.commit()
    except cx_Oracle.DatabaseError, exception:
        error_messages = [
            "Could not delete user {}: {}".format(user_id,
                                                  exception.args[0].message)
        ]
        redirect_url += "?errors=" + urllib.quote_plus(
            json.dumps(error_messages))

    return krait.Response("HTTP/1.1", 302, [("Location", redirect_url)], "")