Conditional redirect based on authentication using state to save original url request