예제 #1
0
파일: db.py 프로젝트: kiwipxl/Flesh-cpp
def find_user_account(username, password):
    global cur;

    username, password, err = accounts.format_user_pass(username, password);
    if (err == False): return accounts.LoginResult.INVALID_FORMAT, -1;

    result = query("select * from accounts where user=? and pass=?", (username, password));
    if not (result): return accounts.LoginResult.UNKNOWN_ERROR, -1;
    fetch = cur.fetchone();
    if (fetch == None): return accounts.LoginResult.INCORRECT_USER_OR_PASS, -1;

    return accounts.LoginResult.SUCCESS, fetch["id"];
예제 #2
0
파일: db.py 프로젝트: kiwipxl/Flesh-cpp
def find_user_account(username, password):
    global cur

    username, password, err = accounts.format_user_pass(username, password)
    if (err == False): return accounts.LoginResult.INVALID_FORMAT, -1

    result = query("select * from accounts where user=? and pass=?",
                   (username, password))
    if not (result): return accounts.LoginResult.UNKNOWN_ERROR, -1
    fetch = cur.fetchone()
    if (fetch == None): return accounts.LoginResult.INCORRECT_USER_OR_PASS, -1

    return accounts.LoginResult.SUCCESS, fetch["id"]
예제 #3
0
파일: db.py 프로젝트: kiwipxl/Flesh-cpp
def add_user_account(username, password):
    global con;
    global cur;

    username, password, err = accounts.format_user_pass(username, password);
    if (err == False): return accounts.RegisterResult.INVALID_FORMAT;

    query("select * from accounts where user=?", (username, ));
    if (cur.fetchone() != None): return accounts.RegisterResult.USER_ALREADY_EXISTS;

    result = query("insert or ignore into accounts(user, pass, gold, last_login_time, last_logout_time, total_login_time) \
                    values(?, ?, ?, ?, ?, ?)", (username, password, accounts.STARTING_GOLD, 0, 0, 0));
    if not (result): return accounts.RegisterResult.UNKNOWN_ERROR;

    return accounts.RegisterResult.SUCCESS;
예제 #4
0
파일: db.py 프로젝트: kiwipxl/Flesh-cpp
def add_user_account(username, password):
    global con
    global cur

    username, password, err = accounts.format_user_pass(username, password)
    if (err == False): return accounts.RegisterResult.INVALID_FORMAT

    query("select * from accounts where user=?", (username, ))
    if (cur.fetchone() != None):
        return accounts.RegisterResult.USER_ALREADY_EXISTS

    result = query(
        "insert or ignore into accounts(user, pass, gold, last_login_time, last_logout_time, total_login_time) \
                    values(?, ?, ?, ?, ?, ?)",
        (username, password, accounts.STARTING_GOLD, 0, 0, 0))
    if not (result): return accounts.RegisterResult.UNKNOWN_ERROR

    return accounts.RegisterResult.SUCCESS