Undercover policing is a necessary evil - but we must learn from its mistakes