Skip to content

Commit

Permalink
adjustment for 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kanda999 committed Dec 13, 2024
1 parent 2d053ca commit 25a6a1b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion website_recaptcha_v2/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
2 changes: 1 addition & 1 deletion website_recaptcha_v2_form/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": """
Expand Down
10 changes: 5 additions & 5 deletions website_recaptcha_v2_form/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions website_recaptcha_v2_form/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import website
from . import res_users
23 changes: 23 additions & 0 deletions website_recaptcha_v2_form/models/res_users.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 25a6a1b

Please sign in to comment.