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