Skip to content

Commit

Permalink
ApplicationContent should pass cookies to final response. Issue feinc…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin J. Laubach committed Jul 20, 2023
1 parent 3f25432 commit a64d249
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions feincms/content/application/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ def process(self, request, **kw):
if h in output:
self.rendered_headers.setdefault(h, []).append(output[h])

application_cookies = output.cookies
if application_cookies:
self.rendered_headers['X-Feincms-Cookie'] = application_cookies

elif isinstance(output, tuple) and "view" in kw:
kw["view"].template_name = output[0]
kw["view"].request._feincms_extra_context.update(output[1])
Expand Down Expand Up @@ -420,6 +424,15 @@ def _update_response_headers(self, request, response, headers):
if len(lm_list) > 0:
response["Expires"] = http_date(mktime(min(lm_list)))

# Add all cookies
cookies = headers.get('X-Feincms-Cookie', None)
if cookies:
for kookie, val in cookies.items():
response.set_cookie(kookie, value=val.value,
max_age=val['max-age'], expires=val['expires'], path=val['path'],
domain=val['domain'], secure=val['secure'], httponly=val['httponly'],
samesite=val['samesite'])

@classmethod
def app_reverse_cache_key(self, urlconf_path, **kwargs):
return "FEINCMS:{}:APPCONTENT:{}:{}".format(
Expand Down

0 comments on commit a64d249

Please sign in to comment.