summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/website_form/controllers/main.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py
index 3d3bdb87812..1d4daba4cff 100644
--- a/addons/website_form/controllers/main.py
+++ b/addons/website_form/controllers/main.py
@@ -36,8 +36,13 @@ class WebsiteForm(http.Controller):
raise BadRequest('Session expired (invalid CSRF token)')
try:
- if request.env['ir.http']._verify_request_recaptcha_token('website_form'):
- return self._handle_website_form(model_name, **kwargs)
+ # The except clause below should not let what has been done inside
+ # here be committed. It should not either roll back everything in
+ # this controller method. Instead, we use a savepoint to roll back
+ # what has been done inside the try clause.
+ with request.env.cr.savepoint():
+ if request.env['ir.http']._verify_request_recaptcha_token('website_form'):
+ return self._handle_website_form(model_name, **kwargs)
error = _("Suspicious activity detected by Google reCaptcha.")
except (ValidationError, UserError) as e:
error = e.args[0]