class Middleware:
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
request = Request(environ)
cookies = request.cookies
path = request.path
if not isAuthenticated(cookies):
#Redirect to /login
return self.app(environ, start_response)
So I have a Middleware
class that is supposed to get the cookies
from the request
and then send it to a function isAuthenticated
which returns either True
or False
now if the function returns False
I need to redirect to /login
page is that possible to do? even though I don't have the request
object I only have the environ
?