Exemplo n.º 1
0
def add_session(uid):
    sid = get_new_sid()
    c.execute("INSERT INTO Sessions (sid, uid) VALUES(:sid, :uid)", {
        "sid": sid,
        "uid": uid
    })
    return sid
Exemplo n.º 2
0
def add_user(username, password, charname, email):
    # Verification
    if not is_valid.username(username):
        return False
    if not is_valid.password(password):
        return False
    if not is_valid.email(email):
        return False
    if not is_valid.charname(charname):
        return False

    salt = get_salt()
    data = {
        "uid": get_new_uid(),
        "username": username,
        "hash": get_hash(password, salt),
        "salt": salt,
        "pid": 1,
        "charname": charname,
        "email": email
    }
    c.execute(
        """INSERT INTO Users (uid, username, hash, salt, pid, charname, email)
                             VALUES(:uid, :username, :hash, :salt, :pid, :charname, :email)""",
        data)
    return True
Exemplo n.º 3
0
def verify_session(sid):
    c.execute("SELECT uid FROM Sessions WHERE sid = :sid", {"sid": sid})
    res = c.fetchone()
    if res is not None:
        return res[0]
    else:
        return None
Exemplo n.º 4
0
def verify_user(username, password):
    c.execute("SELECT uid,hash,salt FROM Users WHERE username = :username",
              {"username": username})
    res = c.fetchone()
    if res is not None:
        if res[1] == get_hash(password, res[2]):
            return res[0]
    else:
        return None
Exemplo n.º 5
0
def build(uid):
    if uid == False and uid is not 0:
        return GLOBAL.tresspass()

    html = GLOBAL.HTML()

    # DO DATABASESTUFF HERE WITH UID
    c.execute("SELECT username FROM Users WHERE uid = :uid", {"uid": uid})
    username = c.fetchone()[0]

    html.add(GLOBAL.STARTDOC("JIR Dashboard"))

    html.add(GLOBAL.navbar(username))

    html.add(GLOBAL.sidebar("dashboard"))

    html.add(GLOBAL.S_main())  # main start

    html.add(GLOBAL.pathbar(["Dashboard"]))
    html.add(GLOBAL.title("Dashboard"))

    html.add(
        LOCAL.r_overview("Active Investments", 120, "Active Bonds", 82,
                         "New Members", 24, "Reserve Assets", "5.2T"))

    html.add(LOCAL.r_chart("Profit Review (2014)"))  #chart is built elsewear?

    html.add(
        LOCAL.r_growth_overview("Active Investments Growth", 45,
                                "Active Bonds Growth", 65,
                                "New Members Growth", 48,
                                "Reserve Assets Growth", 27))

    html.add(GLOBAL.S_row())  # row start

    chatdata = [
        chat.message(
            "Doc Pope", "32 min ago",
            "Hello, world!"),  # shouldRet a <li class="left clearfix">
        chat.message("Doc Pope", "28 min ago", "Hello, world!"),
        chat.message("Doc Pope", "24 min ago", "Hello, world!")
    ]
    html.add(
        chat.c_chat(chatdata)
    )  #  shouldRet a <div class="col-md-8">  with all things surounding the li's

    html.add(panel.c_basic("col-md-4", "panel-danger", "heading", "body"))

    html.add(GLOBAL.F_row())

    html.add(GLOBAL.F_main())

    html.add(GLOBAL.ENDDOC())  #includes scripts and such

    return html.body
Exemplo n.º 6
0
def drop_session(sid):
    c.execute("DELETE FROM Sessions WHERE sid = :sid", {"sid": sid})
    return sid