Ejemplo n.º 1
0
    def store(self, auth: Auth, request: Request,
              response: Response):  # store register user
        user = auth.register(request.only("name", "email", "password"))

        if not user:
            return response.redirect("/register")

        return response.redirect("/home")
Ejemplo n.º 2
0
    def store(self, view: View, request: Request, auth: Auth, response: Response):
        login = auth.attempt(request.input("username"), request.input("password"))

        if login:
            return response.redirect(name="home")

        # Go back to login page
        return response.redirect(name="login")
Ejemplo n.º 3
0
class TestResponseRedirect(TestCase):
    def setUp(self):
        application = Application(os.getcwd())
        self.response = Response(application)

    def test_download(self):
        self.response.download("invoice",
                               "tests/integrations/storage/invoice.pdf",
                               force=True)
        self.assertTrue(self.response.header("Content-Disposition"))
        self.assertEqual(
            self.response.header("Content-Disposition"),
            'attachment; filename="invoice.pdf"',
        )
Ejemplo n.º 4
0
 def setUp(self):
     self.app = App()
     self.request = Request(wsgi_request.copy()).key(
         'NCTpkICMlTXie5te9nJniMj9aVbPM6lsjeq5iDZ0dqY=').load_app(self.app)
     self.app.bind('Request', self.request)
     self.response = Response(self.app)
     self.app.simple(Response)
Ejemplo n.º 5
0
    def store_changed_password(
        self, auth: Auth, request: Request, response: Response
    ):  # store password_reset record
        auth.reset_password(request.input("password"), request.input("token"))

        # Need to validate??
        # Redirect back?
        return response.back()
Ejemplo n.º 6
0
class TestResponseRedirect(TestCase):
    def setUp(self):
        super().setUp()
        self.addRoutes(Route.get("/", None).name("home-redirect"))
        self.response = Response(self.application)

    def test_redirect(self):
        self.response.redirect("/")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(self.response.header_bag.get("Location").value, "/")

    def test_redirect_to_route_named_route(self):
        self.response.redirect(name="home-redirect")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(self.response.header_bag.get("Location").value, "/")

    def test_redirect_to_url(self):
        self.response.redirect(url="/login")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(self.response.header_bag.get("Location").value, "/login")
Ejemplo n.º 7
0
class TestResponseRedirect(TestCase):
    def setUp(self):
        application = Application(os.getcwd())
        application.bind("router",
                         RouteCapsule(Route.get("/", None).name("home")))
        self.response = Response(application)

    def test_redirect(self):
        self.response.redirect("/")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(self.response.header_bag.get("Location").value, "/")

    def test_redirect_to_route_named_route(self):
        self.response.redirect(name="home")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(self.response.header_bag.get("Location").value, "/")

    def test_redirect_to_url(self):
        self.response.redirect(url="/login")
        self.assertEqual(self.response.get_status(), 302)
        self.assertEqual(
            self.response.header_bag.get("Location").value, "/login")
Ejemplo n.º 8
0
 def setUp(self):
     application = Application(os.getcwd())
     self.response = Response(application)
Ejemplo n.º 9
0
 def setUp(self):
     application = Application(os.getcwd())
     application.bind("router",
                      RouteCapsule(Route.get("/", None).name("home")))
     self.response = Response(application)
Ejemplo n.º 10
0
 def setUp(self):
     super().setUp()
     self.addRoutes(Route.get("/", None).name("home-redirect"))
     self.response = Response(self.application)
Ejemplo n.º 11
0
 def response_int(self, response: Response):
     return response.view(1)
Ejemplo n.º 12
0
 def redirect(self, response: Response):
     return response.redirect('/some/test')
Ejemplo n.º 13
0
 def test_json(self, response: Response):
     return response.json({'test': 'value'})