예제 #1
0
def check_auth(username, password):
    """
    Function checks is username and password is valid.
    Funciton shall make a database call to verify the
    username and password exists on the database via
    hashing.
    """
    # create new DB communication object
    # and check for a valid login
    db = DBComm()
    # Check if user exists
    if db.is_a_user(str(username)):
        # Convert string password to md5 hash format
        password_hash = hashlib.md5(str(password)).hexdigest()
        # Check username with password
        return (db.is_valid_login(
           str(username),
           str(password_hash)))
    # The file doesn't exist, the user doesn't exist,
    # or the username-password combination isn't valid.
    return False
예제 #2
0
def getCurrentClientState(username):
    db = DBComm()
    client = db.get_user_client_state(str(username))
    return client