diff --git a/auth_signup_verify_email/__manifest__.py b/auth_signup_verify_email/__manifest__.py index 518663e3c3..5a23afd74e 100644 --- a/auth_signup_verify_email/__manifest__.py +++ b/auth_signup_verify_email/__manifest__.py @@ -7,20 +7,11 @@ "category": "Authentication", "website": "https://github.com/OCA/server-auth", "author": "Antiun IngenierĂ­a S.L., " - "Tecnativa, " - "Odoo Community Association (OCA)", + "Tecnativa, " + "Odoo Community Association (OCA)", "license": "AGPL-3", - "depends": [ - "auth_signup", - ], - "external_dependencies": { - "python": [ - "lxml", - "email_validator", - ], - }, - "data": [ - "views/signup.xml", - ], - 'installable': True, + "depends": ["auth_signup"], + "external_dependencies": {"python": ["lxml", "email_validator"]}, + "data": ["views/signup.xml"], + "installable": True, } diff --git a/auth_signup_verify_email/controllers/main.py b/auth_signup_verify_email/controllers/main.py index f2468b8fac..8f5fcfb5a4 100644 --- a/auth_signup_verify_email/controllers/main.py +++ b/auth_signup_verify_email/controllers/main.py @@ -2,21 +2,21 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import logging -from email_validator import validate_email, EmailSyntaxError, \ - EmailUndeliverableError + +from email_validator import EmailSyntaxError, EmailUndeliverableError, validate_email + from odoo import _ from odoo.http import request, route + from odoo.addons.auth_signup.controllers.main import AuthSignupHome _logger = logging.getLogger(__name__) class SignupVerifyEmail(AuthSignupHome): - @route() def web_auth_signup(self, *args, **kw): - if (request.params.get("login") and not - request.params.get("password")): + if request.params.get("login") and not request.params.get("password"): return self.passwordless_signup() return super().web_auth_signup(*args, **kw) @@ -29,9 +29,7 @@ def passwordless_signup(self): validate_email(values.get("login", "")) except EmailSyntaxError as error: qcontext["error"] = getattr( - error, - "message", - _("That does not seem to be an email address."), + error, "message", _("That does not seem to be an email address."), ) return request.render("auth_signup.signup", qcontext) except EmailUndeliverableError as error: @@ -44,12 +42,11 @@ def passwordless_signup(self): values["email"] = values.get("login") # preserve user lang - values['lang'] = request.lang + values["lang"] = request.lang # Remove password values["password"] = "" - sudo_users = (request.env["res.users"] - .with_context(create_user=True).sudo()) + sudo_users = request.env["res.users"].with_context(create_user=True).sudo() try: with request.cr.savepoint(): @@ -58,16 +55,19 @@ def passwordless_signup(self): except Exception as error: # Duplicate key or wrong SMTP settings, probably _logger.exception(error) - if request.env["res.users"].sudo().search( - [("login", "=", qcontext.get("login"))]): + if ( + request.env["res.users"] + .sudo() + .search([("login", "=", qcontext.get("login"))]) + ): qcontext["error"] = _( - "Another user is already registered using this email" - " address.") + "Another user is already registered using this email" " address." + ) else: # Agnostic message for security qcontext["error"] = _( - "Something went wrong, please try again later or" - " contact us.") + "Something went wrong, please try again later or" " contact us." + ) return request.render("auth_signup.signup", qcontext) qcontext["message"] = _("Check your email to activate your account!") diff --git a/auth_signup_verify_email/tests/test_verify_email.py b/auth_signup_verify_email/tests/test_verify_email.py index aeaea02271..8bb3060f68 100644 --- a/auth_signup_verify_email/tests/test_verify_email.py +++ b/auth_signup_verify_email/tests/test_verify_email.py @@ -1,12 +1,14 @@ # Copyright 2016 Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from mock import patch from lxml.html import document_fromstring +from mock import patch + from odoo.tests.common import HttpCase -from odoo.addons.mail.models import mail_template from odoo.tools.misc import mute_logger +from odoo.addons.mail.models import mail_template + class UICase(HttpCase): def setUp(self): @@ -14,11 +16,9 @@ def setUp(self): if "website" in self.env: # Enable public signup in website if it is installed; otherwise # tests here would fail - current_website = self.env['website'].get_current_website() + current_website = self.env["website"].get_current_website() current_website.auth_signup_uninvited = "b2c" - self.env["ir.config_parameter"].set_param( - "auth_signup.invitation_scope", "b2c" - ) + self.env["ir.config_parameter"].set_param("auth_signup.invitation_scope", "b2c") self.data = { "csrf_token": self.csrf_token(), "name": "Somebody", @@ -41,7 +41,7 @@ def test_bad_email(self): 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') + @mute_logger("odoo.addons.auth_signup_verify_email.controllers.main") def test_good_email(self): """Test acceptance of good emails.""" self.data["login"] = "good@example.com" diff --git a/auth_signup_verify_email/views/signup.xml b/auth_signup_verify_email/views/signup.xml index 0a55571a4b..49b44e7b0e 100644 --- a/auth_signup_verify_email/views/signup.xml +++ b/auth_signup_verify_email/views/signup.xml @@ -1,20 +1,16 @@ - + - - - +