diff --git a/website_recaptcha_v2/__manifest__.py b/website_recaptcha_v2/__manifest__.py index f8486bf..9aba64b 100644 --- a/website_recaptcha_v2/__manifest__.py +++ b/website_recaptcha_v2/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Website reCAPTCHA v2", - "version": "16.0.1.0.0", + "version": "15.0.1.0.0", "category": "Website", "depends": ["website"], "author": ( diff --git a/website_recaptcha_v2_form/__manifest__.py b/website_recaptcha_v2_form/__manifest__.py index 59cc317..3f42956 100644 --- a/website_recaptcha_v2_form/__manifest__.py +++ b/website_recaptcha_v2_form/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Website reCAPTCHA v2 form", - "version": "16.0.1.0.0", + "version": "15.0.1.0.0", "category": "Website", "depends": ["web", "auth_signup", "website", "website_recaptcha_v2"], "author": """ diff --git a/website_recaptcha_v2_form/controllers/main.py b/website_recaptcha_v2_form/controllers/main.py index 23f6e7e..ac9efe9 100644 --- a/website_recaptcha_v2_form/controllers/main.py +++ b/website_recaptcha_v2_form/controllers/main.py @@ -5,7 +5,7 @@ from odoo.http import request from odoo.addons.auth_signup.controllers.main import AuthSignupHome -from odoo.addons.web.controllers.home import SIGN_UP_REQUEST_PARAMS, Home +from odoo.addons.web.controllers.main import SIGN_UP_REQUEST_PARAMS, Home logger = logging.getLogger(__name__) @@ -20,7 +20,7 @@ def verify_recaptcha_v2(self, args=None, kw=None, template="", values=None): valid = Website.get_current_website().valid_recaptcha(values) if valid: if template == "web.login": - return super().web_login(values.get("redirect", ""), **kw) + return super().web_login(**kw) if template in ("auth_signup.reset_password", "auth_signup.signup"): return True except AccessDenied as e: @@ -36,8 +36,8 @@ def verify_recaptcha_v2(self, args=None, kw=None, template="", values=None): response.headers["Content-Security-Policy"] = "frame-ancestors 'self'" return response - @http.route("/web/login", type="http", auth="none") - def web_login(self, redirect=None, **kw): + @http.route() + def web_login(self, *args, **kw): if request.httprequest.method == "POST": values = { k: v for k, v in request.params.items() if k in SIGN_UP_REQUEST_PARAMS @@ -52,7 +52,7 @@ def web_login(self, redirect=None, **kw): return self.verify_recaptcha_v2( kw=kw, template="web.login", values=values ) - return super().web_login(redirect, **kw) + return super().web_login(*args, **kw) class BinhexAuthSignupHome(AuthSignupHome): diff --git a/website_recaptcha_v2_form/models/__init__.py b/website_recaptcha_v2_form/models/__init__.py index bd190fa..3df56a5 100644 --- a/website_recaptcha_v2_form/models/__init__.py +++ b/website_recaptcha_v2_form/models/__init__.py @@ -1 +1,2 @@ from . import website +from . import res_users diff --git a/website_recaptcha_v2_form/models/res_users.py b/website_recaptcha_v2_form/models/res_users.py new file mode 100644 index 0000000..a03cc2f --- /dev/null +++ b/website_recaptcha_v2_form/models/res_users.py @@ -0,0 +1,23 @@ +# Copyright 2024 Quartile Limited + +""" +When using this module together with the OCA module auth_signup_verify_email, +an error occurs in the _signup_create_user method stating +that g-recaptcha-response does not exist in res.users. +Additionally, it is not possible to create a g-recaptcha-response field in res.users +because Python cannot use a hyphen (-) in field names. +Therefore, this method is necessary. +Task:4999 +""" + +from odoo import api, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + @api.model + def _signup_create_user(self, values): + if "g-recaptcha-response" in values: + values.pop("g-recaptcha-response") + return super(ResUsers, self)._signup_create_user(values)