For a few sites where we're using a custom module that we've integrated into masquerade we've often ran into an issue with when you switch back from a user you end up on the page you clicked switch back on, which you may or may not have access to. For instance you switched to a user with permission for changing the theme from one without that permission, and on the theme settings page you click switch back and get greeted by a nice access denied message.
I'd propose we should be able to pass a 'return' url to the switch page, which stores the url and when you switch back it calls drupal_goto on that url instead of the referrer if its set.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1538428-masq-url-6.patch | 3.19 KB | andypost |
#1 | masquerade-1538428-switch-back-return-url.patch | 1.21 KB | jrreid |
Comments
Comment #1
jrreid CreditAttribution: jrreid commentedHere is my proposed patch, rolled against head
Comment #2
andypostSuppose this way wrong, simply you just need to hijack global referer in you custom module, I see no actual reason to store another variable in session
Also your code does not follow http://drupal.org/coding-standards
Comment #3
deekayen CreditAttribution: deekayen commenteddestination is the traditional drupal get variable for setting redirects. there's already some built-in core support for that var.
Comment #4
jrreid CreditAttribution: jrreid commented?destination=blah however influences where you go when you click on a masquerade link, in this case sending the masqueraded user to blah after the switch and already works as expected. This return url setting is to control where you go back to after you've clicked switch back.
Comment #5
andypostSuppose storing of return url in session makes no sense. But allow to handle common 'destination' a thing we should done.
Comment #6
andypostHere's a patch:
- adds destination to all links
- form submission does not need got at all
- switch callbacks analyzes 'destination' parameter first
Comment #7
andypost@deekayen are you agree to commit this?
This hunk are required to fix
Comment #8
obleser CreditAttribution: obleser commentedThought it would be a better approach to create 2 "Triggers" which are triggered on switch and unswitch?
Then it would be possible to do a hole bunch if things, not only a redirect ;)
Just a thought...
Comment #10
jenlamptonI second the approach in #8. I just recommended the same thing over in https://drupal.org/node/763972#comment-8266267