mblackgeo / flask-cognito-lib

A Flask extension that supports protecting routes with AWS Cognito following OAuth 2.1 best practices
https://mblackgeo.github.io/flask-cognito-lib/
MIT License
57 stars 15 forks source link

How to redirect to original route after logging in #46

Closed Ulthran closed 3 weeks ago

Ulthran commented 2 months ago

If you navigate to a route marked with @authrequired, after successful login it will redirect according to whatever is in the postlogin route. How do you set this dynamically based on the original route?

mblackgeo commented 1 month ago

I think the best way would be to store the state value in the session, from the docs:

    # An optional "state" value can be set in the current session which will
    # be passed and then used in the postlogin route (after the user has logged
    # into the Cognito hosted UI); this could be used for dynamic redirects,
    # for example, set `session['state'] = "some_custom_value"` before passing
    # the user to this route