stormpath / express-stormpath

Build simple, secure web applications with Stormpath and Express!
http://docs.stormpath.com/nodejs/express/
Apache License 2.0
325 stars 111 forks source link

Expose RouterMethod to push LoginRoute + post-login redirect path #598

Open SanzSeraph opened 7 years ago

SanzSeraph commented 7 years ago

This was meant for the react-stormpath repository.

This is a proposed enhancement, not a bug.

In a situation where the server replies with a 401 (for example, if you are using express-stormpath to validate AccessTokens,) it would be very useful to have a built-in way to push the login path with the "?next" parameter set to a prescribed path.

this.props.router.pushLoginRoute('/mypreviouspath');

This can currently be achieved with this.props.router.push('/myloginpath?next=' + encodeURIComponent('/mypreviouspath')); which is a bit messy.