Keep returnTo when using successReturnToOrRedirect #941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a small patch to fix the behaviour of the
successReturnToOrRedirect
option as illustrated in #919 and #281As I understand it, the
successReturnToOrRedirect
option is supposed to, upon success, return or redirect to the string specified insession.returnTo
or ifsession.returnTo
is not specified then return/redirect to the string specified in thesuccessReturnToOrRedirect
option.The problem with the situation as-is, is that
session.returnTo
is wiped out includingsession.returnTo
and thus the user is always routed towards the default as specified insuccessReturnToOrRedirect
. This behaviour is unexpected and one would expect that when you have set areturnTo
value in the session and also specified thesuccessReturnToOrRedirect
option that the user would be directed towards the value specified in the session. As described in #919, there is a workaround by setting thekeepSessionInfo
option to true but this workaround involves keeping all of the previous session values rather than the minimal set required forsuccessReturnToOrRedirect
to operated as expected.This patch ensures that if
successReturnToOrRedirect
is being used and the session contains areturnTo
value that thesession.returnTo
value is maintained and thus the expected behaviour is implemented.Checklist
$ make test
) executes successfully.$ make lint
) executes successfully.