How configure custom authentication flow (Username and Password form + SMS Auth as Alternative)


I want to implement custom authentication flow:
1.The user is authenticated if username and password is valid
2. If password invalid, user clicks on “Forgot password” link
2. The user redirects on custom SMS Auth form
3. The user enters code
5. The user is authenticated

My authentication flow is now