Beispiel #1
0
def logsToday():
    username = get_username()
    retval = p_database.check_username(username)
    if username and retval:
        liOfLi = p_database.logsToday()
        return json.dumps(liOfLi)
    return json.dumps({'message': "problem loading log"})
Beispiel #2
0
def logsSpecefic():
    username = get_username()
    retval = p_database.check_username(username)
    if username and retval:
        content = bottle.request.body.read().decode()
        content = decryptt(content)
        cred = json.loads(content)
        Cdate = other.dateCorrect(cred)
        data = p_database.filterLogs(Cdate)
        return json.dumps(data)
    return json.dumps({'message': "problem loading log"})
Beispiel #3
0
def addwork():
    username = get_username()
    retval = p_database.check_username(username)
    if username and retval:
        content = bottle.request.body.read().decode()
        content = decryptt(content)
        cred = json.loads(content)
        cred['username'] = username
        message = p_database.addWork(cred)
        return json.dumps(message)
    return json.dumps({'message': "log not added"})
Beispiel #4
0
def add_user(dic):
    for i in dic.values():
        if i == "":
            return "Any Field can not be left empty"
    username = html.escape(dic["username"])
    password = html.escape(dic["password"])
    email = html.escape(dic["email"])
    phoneNumber = html.escape(dic["phoneNumber"])
    if db.check_username(username):
        return "username \"" + username + "\" already exists"
    if db.check_email(email):
        return "A user with Email ID \"" + email + "\" already exists"

    db.add_creds(username, password, email, phoneNumber)
    return username + " registered"
Beispiel #5
0
def authenticate(dic):
    resp = {
        "authenticated": False,
        "message": "Username and Password can not be left empty"
    }
    username = html.escape(dic["username"])
    password = html.escape(dic["password"])
    if username == "" or password == "":
        return resp
    result = login_atmpt(username)
    if not db.check_username(username):
        resp["message"] = "username \"" + username + "\" does not exist"
        return resp
    elif db.validate_creds(username, password):
        resp = {"authenticated": True, "message": "welcome " + username}
        return resp
    else:
        resp = {"authenticated": False, "message": " password incorrect"}
        return resp
Beispiel #6
0
def dashboard_page(filename):
    username = get_username()
    retval = p_database.check_username(username)
    if username and retval:
        return bottle.static_file("frontend/" + filename, root=".")
    return None