(self, request)
return HttpResponseRedirect(DEFAULT_LOGIN_REDIRECT)
Carries out the login, redirects to get if it fails
Carries out the login, redirects to get if it fails
Carries out the login redirects to get if it fails
def post(self, request):
        """Carries out the login, redirects to get if it fails"""

        # redirect target on successful login
        next_page = request.POST.get("next", "")

        # redirect target on failed login
        login_page = "{page}?next={next_page}".format(
            page=reverse("login"), next_page=next_page
        )

        username = request.POST.get("user", None)
        if not username:
            messages.error(request, _("Username missing"))
            return HttpResponseRedirect(login_page)

        password = request.POST.get("pwd", None)
        if not password:
            messages.error(request, _("Password missing"))
            return HttpResponseRedirect(login_page)

        # find the user from the configured login systems, and verify pwd
        user = authenticate(username=username, password=password)

        if not user:
            messages.error(request, _("Wrong username or password."))
            return HttpResponseRedirect(login_page)

        if not user.is_active:
            send_activation_email(user, request)
            messages.error(
                request,
                _(
                    "Please activate your account first. "
                    "We have just re-sent your activation email"
                ),
            )
            return HttpResponseRedirect(login_page)

        # set up the user's session
        login(request, user)

        if next_page:

            domain = RequestSite(request).domain
            allowed_hosts = [domain]
            if is_safe_url(next_page, allowed_hosts):
                return HttpResponseRedirect(next_page)

            else:
                # TODO: log a warning that next_page is not
                # considered a safe redirect target
                pass

        return HttpResponseRedirect(DEFAULT_LOGIN_REDIRECT)
def post ( self , request ) : # redirect target on successful login next_page = request . POST . get ( "next" , "" ) # redirect target on failed login login_page = "{page}?next={next_page}" . format ( page = reverse ( "login" ) , next_page = next_page ) username = request . POST . get ( "user" , None ) if not username : messages . error ( request , _ ( "Username missing" ) ) return HttpResponseRedirect ( login_page ) password = request . POST . get ( "pwd" , None ) if not password : messages . error ( request , _ ( "Password missing" ) ) return HttpResponseRedirect ( login_page ) # find the user from the configured login systems, and verify pwd user = authenticate ( username = username , password = password ) if not user : messages . error ( request , _ ( "Wrong username or password." ) ) return HttpResponseRedirect ( login_page ) if not user . is_active : send_activation_email ( user , request ) messages . error ( request , _ ( "Please activate your account first. " "We have just re-sent your activation email" ) , ) return HttpResponseRedirect ( login_page ) # set up the user's session login ( request , user ) if next_page : domain = RequestSite ( request ) . domain allowed_hosts = [ domain ] if is_safe_url ( next_page , allowed_hosts ) : return HttpResponseRedirect ( next_page ) else : # TODO: log a warning that next_page is not # considered a safe redirect target pass return HttpResponseRedirect ( DEFAULT_LOGIN_REDIRECT )