code: def authenticated(self):
          
          # Try to get the current :class:`models.User<cas_server.models.User>` object for the current
          # session
          try:
              self.user = models.User.objects.get(
                  username=self.request.session.get("username"),
                  session_key=self.request.session.session_key
              )
          # if not found, flush the session and redirect to the login page
          except models.User.DoesNotExist:
              logger.warning(
                  "User %s seems authenticated but is not found in the database." % (
                      self.request.session.get("username"),
                  )
              )
              self.logout()
              if self.ajax:
                  data = {
                      "status": "error",
                      "detail": "login required",
                      "url": utils.reverse_params("cas_server:login", params=self.request.GET)
                  }
                  return json_response(self.request, data)
              else:
                  return utils.redirect_params("cas_server:login", params=self.request.GET)
  
          # if login against a service
          if self.service:
              return self.service_login()
          # else display the logged template
          else:
              if self.ajax:
                  data = {"status": "success", "detail": "logged"}
                  return json_response(self.request, data)
              else:
                  return render(
                      self.request,
                      settings.CAS_LOGGED_TEMPLATE,
                      utils.context({'session': self.request.session})
                  )
docs: Processing authenticated users
  
              :return:
                  * The returned value of :meth:`service_login` if :attr:`service` is defined
                  * The rendering of ``settings.CAS_LOGGED_TEMPLATE`` otherwise
              :rtype: django.http.HttpResponse