Ticket #2210: PermRedirect-urlfix.2.diff

File PermRedirect-urlfix.2.diff, 1.1 kB (added by UnwashedMeme, 1 month ago)

Patch to the 0.11 branch to use the referer querystring parameter (now slightly improved to also capture the querystring of the original request instead of just the request path).

  • permredirect/filter.py

    old new  
    2424                return template, data, content_type 
    2525             
    2626            exctype, exc = sys.exc_info()[0:2] 
     27            ref_url = req.base_url + req.path_info 
     28            if(req.query_string): ref_url = ref_url + "?" + req.query_string 
     29            login_url = req.href.login(referer=ref_url) 
    2730            if issubclass(exctype, PermissionError): 
    28                 req.redirect(req.href.login()
     31                req.redirect(login_url
    2932             
    3033            try: 
    3134                if req.path_info.startswith('/admin') and \ 
    3235                   not AdminModule(self.env)._get_panels(req)[0]: 
    3336                    # No admin panels available, assume user should log in. 
    34                     req.redirect(req.href.login()
     37                    req.redirect(login_url
    3538            except RequestDone: 
    3639                # Reraise on redirect 
    3740                raise