Brodie Rao avatar Brodie Rao committed 2602cfa

Minor refactoring

Comments (0)

Files changed (2)

django_cas/middleware.py

                          'privileges.</p>')
                 return HttpResponseForbidden(error)
         params = urlencode({REDIRECT_FIELD_NAME: request.get_full_path()})
-        url = reverse(cas_login)
-        return HttpResponseRedirect(url + '?' + params)
+        return HttpResponseRedirect(reverse(cas_login) + '?' + params)

django_cas/views.py

     params = {'service': service}
     if settings.CAS_EXTRA_LOGIN_PARAMS:
         params.update(settings.CAS_EXTRA_LOGIN_PARAMS)
-    url = urljoin(settings.CAS_SERVER_URL, 'login') + '?' + urlencode(params)
-    return url
+    return urljoin(settings.CAS_SERVER_URL, 'login') + '?' + urlencode(params)
 
 
 def _logout_url(request, next_page=None):
     ticket = request.GET.get('ticket')
     service = _service_url(request, next_page)
     if ticket:
-        from django.contrib.auth import authenticate, login
-        user = authenticate(ticket=ticket, service=service)
+        from django.contrib import auth
+        user = auth.authenticate(ticket=ticket, service=service)
         if user is not None:
-            login(request, user)
+            auth.login(request, user)
             name = user.first_name or user.username
             message = "Login succeeded. Welcome, %s." % name
             user.message_set.create(message=message)
             error = "<h1>Forbidden</h1><p>Login failed.</p>"
             return HttpResponseForbidden(error)
     else:
-        url = _login_url(service)
-        return HttpResponseRedirect(url)
+        return HttpResponseRedirect(_login_url(service))
 
 
 def logout(request, next_page=None):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.