def _login_user(self, user): """ Log the >user< in. Used in self._check_plaintext_password() and self._sha_login() Returns a redirect, if "next_url" exists otherwise returns None (for display the current page). """ self.page_msg.green(_("Password ok.")) login(self.request, user) # rebuild the login/logout link: add_dynamic_context(self.request, self.context) if self.request.user.is_superuser: if settings.ENABLE_INSTALL_SECTION: self.page_msg( _("Info: You should disable the _install section!") ) if settings.DEBUG: self.page_msg( _("Info: settings.DEBUG is on!") ) if self.request.POST.get("next_url","") != "": next_url = self.request.POST['next_url'] # Redirect to next URL return HttpResponseRedirect(next_url)
def logout(self): logout(self.request) # rebuild the login/logout link: add_dynamic_context(self.request, self.context) self.page_msg.green("You logged out.") if not self.current_page.permitViewPublic: # The current page, can't see anonymous users -> redirect to the # default page default_page = Page.objects.default_page url = default_page.get_absolute_url() return HttpResponseRedirect(url)
def _get_context(request, current_page_obj): """ Setup the context with PyLucid objects. For index() and handle_command() views. """ # add additional attribute request.anonymous_view = True context = RequestContext(request) context["PAGE"] = current_page_obj context["URLs"] = URLs(context) # context["URLs"].debug() # For additional JavaScript and StyleSheet information. # JS+CSS from internal_pages or CSS data for pygments # Add into the context object. Would be integraged in the page with the # additional_content middleware. context["js_data"] = [] context["css_data"] = [] # A list of every used html DIV CSS-ID. # used in PyLucid.defaulttags.lucidTag.lucidTagNode._add_unique_div() context["CSS_ID_list"] = [] # add dynamic content into the context (like: login/logout link) add_dynamic_context(request, context) # Add the context to the reponse object. # Used in PyLucid middlewares request.CONTEXT = context # TODO: Remove in PyLucid >v0.8.5 msg = 'Error, see: %s' % PAGE_MSG_INFO_LINK context["messages"] = [mark_safe(msg)] return context