Beispiel #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")
Beispiel #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")
Beispiel #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"',
        )
Beispiel #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)
Beispiel #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()
Beispiel #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")
Beispiel #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")
Beispiel #8
0
 def setUp(self):
     application = Application(os.getcwd())
     self.response = Response(application)
Beispiel #9
0
 def setUp(self):
     application = Application(os.getcwd())
     application.bind("router",
                      RouteCapsule(Route.get("/", None).name("home")))
     self.response = Response(application)
Beispiel #10
0
 def setUp(self):
     super().setUp()
     self.addRoutes(Route.get("/", None).name("home-redirect"))
     self.response = Response(self.application)
Beispiel #11
0
 def response_int(self, response: Response):
     return response.view(1)
Beispiel #12
0
 def redirect(self, response: Response):
     return response.redirect('/some/test')
Beispiel #13
0
 def test_json(self, response: Response):
     return response.json({'test': 'value'})