piwigo: Sent a fake cookie.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 21 Mar 2013 08:01:48 +0000 (09:01 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 21 Mar 2013 08:04:37 +0000 (09:04 +0100)
shotwell needs a pwg_id cookie to continue.
And really, it's the only cookie it supports, so in the
long run, we need to send a proper session cookie as
pwg_id.

mediagoblin/plugins/piwigo/views.py

index 2b6b7b0cb5d491c3dab2663a07313870bac20ea6..d0629b73f914c83b3db0ac1be4657d0ad4c1108a 100644 (file)
@@ -69,6 +69,19 @@ def pwg_categories_getList(request):
         }
 
 
+def possibly_add_cookie(request, response):
+    # TODO: We should only add a *real* cookie, if
+    # authenticated. And if there is no cookie already.
+    if True:
+        response.set_cookie(
+            'pwg_id',
+            "some_fake_for_now",
+            path=request.environ['SCRIPT_NAME'],
+            domain=mg_globals.app_config.get('csrf_cookie_domain'),
+            secure=(request.scheme.lower() == 'https'),
+            httponly=True)
+
+
 @csrf_exempt
 def ws_php(request):
     if request.method not in ("GET", "POST"):
@@ -86,4 +99,8 @@ def ws_php(request):
     if isinstance(result, BaseResponse):
         return result
 
-    return response_xml(result)
+    response = response_xml(result)
+
+    possibly_add_cookie(request, response)
+
+    return response