2 factor authentication is not working with Duo

Forgot to mention that if I do the same thing through Rules(as described here DUO MFA asking users to re-enroll even though they already are registered with DUO), it works like a charm. The problem is rules are deprecated.