1. Peter Sanchez
  2. django-impersonate

Pull requests

#3 Declined
Repository
joshlabs
Branch
default
Repository
petersanchez
Branch
default

send to different url on impersonation stop

Author
  1. Rahul kashyap
Reviewers
Description

Hi, I'm trying to make a change for sending admin to a different url on stopping the impersonation. Please accept this pull request. Please do tell if you think the changes are not good. Thanks, Rahul

  • Learn about pull requests

Comments (1)

  1. Peter Sanchez repo owner

    Rahul,

    Sorry, but I can't accept this patch for a few reasons.

    1) It will change the default behavior for all existing users. In your patch, it will always redirect to the HTTP_REFERRER if present (which it usually is)

    2) The line for "request.session['HTTP_REFERER'] = request.META['HTTP_REFERER']" should do a conditional check or use request.META.get() instead. You leave potential KeyError exceptions open for the edge case that a HTTP_REFERRER header isn't actually sent in the request.

    You can already use the setting IMPERSONATE_REDIRECT_URL to specify the redirect URL.

    If you want it customized on the fly then I suggest adding support for something like:

    ?return=http://your-new-url.com/path/to/your/page/

    Check for 'return' in request.GET, if set, add that value to the session and redirect back there upon logout.

    Make sense? Thoughts?

    Peter