summaryrefslogtreecommitdiff
path: root/addons/web/controllers
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-07-03 12:24:51 +0200
committerChristophe Simonis <chs@odoo.com>2015-08-05 12:01:12 +0200
commitb13553d2b65ae2a5ae9ecf5ee7a56f0b0ab73931 (patch)
tree29e2ab7d846fa973e4335743f254765ce9f0bf14 /addons/web/controllers
parent6f4738e298ae3baa39aabd50c4681b1a6de90643 (diff)
[FIX] web, base: POST requests handling
POST requests on routes with auth="user" are now correctly handled when the user is not connected. Request data (form and files) are stored in the session. Once the user is logged, redirect her to a specific route that will reprocess the original POST request.
Diffstat (limited to 'addons/web/controllers')
-rw-r--r--addons/web/controllers/main.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 5edb152b871..bd5df34e6aa 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -670,6 +670,21 @@ class Proxy(http.Controller):
base_url = request.httprequest.base_url
return Client(request.httprequest.app, BaseResponse).get(path, base_url=base_url).data
+ @http.route('/web/proxy/post/<path:path>', type='http', auth='user', methods=['GET'])
+ def post(self, path):
+ """Effectively execute a POST request that was hooked through user login"""
+ with request.session.load_request_data() as data:
+ if not data:
+ raise werkzeug.exceptions.BadRequest()
+ from werkzeug.test import Client
+ from werkzeug.wrappers import BaseResponse
+ base_url = request.httprequest.base_url
+ query_string = request.httprequest.query_string
+ client = Client(request.httprequest.app, BaseResponse)
+ headers = {'X-Openerp-Session-Id': request.session.sid}
+ return client.post('/' + path, base_url=base_url, query_string=query_string,
+ headers=headers, data=data)
+
class Database(http.Controller):
def _render_template(self, **d):