Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] auth_signup_verify_email: Use reCaptcha #775

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth_signup_verify_email/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Verify email at signup",
"summary": "Force uninvited users to use a good email for signup",
"version": "17.0.1.0.0",
"version": "17.0.1.0.1",
"category": "Authentication",
"website": "https://github.com/OCA/server-auth",
"author": "Antiun Ingeniería S.L., "
Expand Down
3 changes: 3 additions & 0 deletions auth_signup_verify_email/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from email_validator import EmailSyntaxError, EmailUndeliverableError, validate_email

from odoo import _
from odoo.exceptions import UserError
from odoo.http import request, route

from odoo.addons.auth_signup.controllers.main import AuthSignupHome
Expand All @@ -26,6 +27,8 @@ def passwordless_signup(self):

# Check good format of e-mail
try:
if not request.env["ir.http"]._verify_request_recaptcha_token("signup"):
raise UserError(_("Suspicious activity detected by Google reCaptcha."))
validate_email(values.get("login", ""))
except EmailSyntaxError as error:
qcontext["error"] = getattr(
Expand Down
10 changes: 10 additions & 0 deletions auth_signup_verify_email/tests/test_verify_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from odoo.tests.common import HttpCase
from odoo.tools.misc import mute_logger

from odoo.addons.base.models import ir_http
from odoo.addons.mail.models import mail_template


Expand Down Expand Up @@ -45,6 +46,15 @@ def test_bad_email(self):
doc = self.html_doc(data=self.data)
self.assertTrue(doc.xpath('//p[@class="alert alert-danger"]'))

def test_failed_recaptcha(self):
"""Test rejection of failed reCaptcha."""
with patch.object(
ir_http.IrHttp, "_verify_request_recaptcha_token", return_value=False
):
self.data["login"] = "contributors@odoo-community.org"
doc = self.html_doc(data=self.data)
self.assertTrue(doc.xpath('//p[@class="alert alert-danger"]'))

@mute_logger("odoo.addons.auth_signup_verify_email.controllers.main")
def test_good_email(self):
"""Test acceptance of good emails."""
Expand Down