Changeset 8761


Ignore:
Timestamp:
03/04/13 14:58:07 (6 years ago)
Author:
mnagni
Message:

Incomplete - # 22689: [CEDA Site Python Port] Logout link
 http://team.ceda.ac.uk/trac/ceda/ticket/22689

Location:
mauRepo/dj_security_middleware/trunk/dj_security_middleware
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/dj_security_middleware/trunk/dj_security_middleware/__init__.py

    r8752 r8761  
    1 __version__ = '0.0.9' 
     1__version__ = '0.0.10' 
  • mauRepo/dj_security_middleware/trunk/dj_security_middleware/middleware.py

    r8755 r8761  
    108108          
    109109        try: 
     110            url = '%s?%s' % (settings.DJ_SECURITY_LOGIN_SERVICE, _build_login_url(request)) 
    110111            timestamp, userid, tokens, user_data = _is_authenticated(request) 
    111112            request.authenticated_user = {'timestamp': timestamp, \ 
     
    116117            request.session['accountid'] = userid 
    117118        except MissingCookieException as ex: 
    118             LOGGER.info("Missing 'auth_tkt' cookie") 
    119         except DJMiddlewareException as ex:         
    120             LOGGER.info(ex) 
    121             url = '%s?%s' % (settings.DJ_SECURITY_LOGIN_SERVICE, _build_login_url(request)) 
    122             LOGGER.info("error in authentication. Redirecting to %s" % (url)) 
     119            LOGGER.info("Missing 'auth_tkt' cookie. Redirecting to %s" % (url)) 
     120            return HttpResponseRedirect(url) 
     121        except DJMiddlewareException as ex:                     
     122            LOGGER.info("Error in authentication. Redirecting to %s" % (url)) 
    123123            return HttpResponseRedirect(url)            
    124124             
     
    128128def _build_url(request): 
    129129    hostname = socket.getfqdn() 
     130    new_get = request.GET.urlencode() 
     131    if request.REQUEST.has_key(LOGOUT): 
     132        start_index = new_get.find(LOGOUT) 
     133        end_index = new_get.find('&', start_index) 
     134        if end_index == -1: 
     135            end_index = len(new_get) 
     136        new_get = new_get.replace(new_get[start_index: end_index],'') 
    130137    if request.META['SERVER_PORT'] != 80: 
    131138        hostname = "%s:%s" % (hostname, request.META['SERVER_PORT']) 
    132     return 'http://%s%s?%s' % (hostname, request.path, request.GET.urlencode()) 
     139    copy_get = request.GET.copy() 
     140    return 'http://%s%s?%s' % (hostname, request.path, new_get) 
    133141 
    134142def _build_login_url(request): 
Note: See TracChangeset for help on using the changeset viewer.