def register_new_user(access, username, password):
    """ Register a new user & handle duplicate detection """
    if access.user_data(username) is not None:
        raise ValueError("User '%s' already exists!" % username)
    if username in access.pending_users():
        raise ValueError("User '%s' has already registered!" % username)
    access.register(username, password)
    if access.need_admin():
        access.approve_user(username)
        access.set_user_admin(username, True)
        return True
    return False