from user import User

def authenticate( username, password ):
    user = User.find_by_username( username )

    if user and user.password == password:
        return user
    return None


def identity( payload ):
    user_id = payload['identity']
    return User.find_by_id( user_id )