diff --git a/app/yearbook/middleware.py b/app/yearbook/middleware.py index 13e1dcd..38349f0 100644 --- a/app/yearbook/middleware.py +++ b/app/yearbook/middleware.py @@ -25,14 +25,14 @@ USER_MODEL = User # An array of path regexes that will not be processed by the middleware -PUBLIC_PATHS = ['^/public.*','^/$','^/static.*','^/admin'] +PUBLIC_PATHS = ['^/public.*','^/$','^/static.*','^/admin$', '^/media.*'] # A dictionary of path regexes mapping to the roles. A user needs to have all roles in order to be authorized ROLES = { '^/admin.*': ['admin'] } -DEFAULT_ROLES = ['iitd_user'] +DEFAULT_ROLES = ['iitd_user','yearbook_user'] UNAUTHORIZED_HANDLER = lambda request: HttpResponse("Alas You are out of scope! Go get some more permissions dude",status=401) code2dept = { @@ -78,22 +78,22 @@ def __call__(self, request): if(token is not None): try: decoded = jwt.decode(token,self.public_key,algorithms='RS256') - logging.info("jwt.decode run successfully") + # logging.info("jwt.decode run successfully") if(float(decoded['exp']) - time.time() < MAX_TTL_ALLOWED): decoded['user'] = self.refresh(request=request,token={SSO_TOKEN:token}) - logging.info("self.refresh executed") + # logging.info("self.refresh executed") if(not self.authorize_roles(request, decoded['user'])): - logging.info("line 88") + # logging.info("line 88") return UNAUTHORIZED_HANDLER(request) self.assign_user(request, decoded['user']) - logging.info("user assigned") + # logging.info("user assigned") except Exception as err: # print(err) - logging.info("line 95") - logging.info(err) + # logging.info("line 95") + # logging.info(err) return self.redirect(request) else: try: @@ -106,7 +106,7 @@ def __call__(self, request): except Exception as err: print(err) - logging.info("line 109") + # logging.info("line 109") return self.redirect(request) response = self.get_response(request)