Isn't this condition unnecessary? Won't $userProvider be null if not set anyway?