From 3e1c84d5866e46dd3cf9c233bcdce08803c86805 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 28 Oct 2015 16:31:09 +0100 Subject: [PATCH 01/10] Add module auth_signup_verify_email. --- auth_signup_verify_email/README.rst | 84 +++++++++ auth_signup_verify_email/__init__.py | 5 + auth_signup_verify_email/__openerp__.py | 25 +++ .../controllers/__init__.py | 5 + auth_signup_verify_email/controllers/main.py | 52 ++++++ .../static/description/icon.png | Bin 0 -> 10549 bytes .../static/description/icon.svg | 172 ++++++++++++++++++ auth_signup_verify_email/views/signup.xml | 20 ++ 8 files changed, 363 insertions(+) create mode 100644 auth_signup_verify_email/README.rst create mode 100644 auth_signup_verify_email/__init__.py create mode 100644 auth_signup_verify_email/__openerp__.py create mode 100644 auth_signup_verify_email/controllers/__init__.py create mode 100644 auth_signup_verify_email/controllers/main.py create mode 100644 auth_signup_verify_email/static/description/icon.png create mode 100644 auth_signup_verify_email/static/description/icon.svg create mode 100644 auth_signup_verify_email/views/signup.xml diff --git a/auth_signup_verify_email/README.rst b/auth_signup_verify_email/README.rst new file mode 100644 index 00000000000..324821b31c1 --- /dev/null +++ b/auth_signup_verify_email/README.rst @@ -0,0 +1,84 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Verify email at signup +====================== + +This module was written to extend the functionality of public sign up to force +users to provide a valid email address. + +To reinforce this requirement, the user will not need to provide a password at +sign up, but when logging in later for the first time. + +Installation +============ + +* Install validate_email_ with ``pip install validate_email`` or equivalent. + +Configuration +============= + +To configure this module, you need to: + +* `Properly configure your outgoing email server(s) + `_. +* Go to *Settings > Configuration > General Settings* and enable *Allow + external users to sign up*. + +Usage +===== + +To use this module, you need to: + +* Log out. +* `Sign up `_ with a valid email. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/186/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. + +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and +welcomed feedback `here `_. + + +Credits +======= + +Icon +---- + +* https://openclipart.org/detail/3040/thumbtack-note-email +* https://openclipart.org/detail/202732/check-mark + +Contributors +------------ + +* Rafael Blasco +* Jairo Llopis + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. + +.. _validate_email: https://pypi.python.org/pypi/validate_email diff --git a/auth_signup_verify_email/__init__.py b/auth_signup_verify_email/__init__.py new file mode 100644 index 00000000000..35233d377a8 --- /dev/null +++ b/auth_signup_verify_email/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import controllers diff --git a/auth_signup_verify_email/__openerp__.py b/auth_signup_verify_email/__openerp__.py new file mode 100644 index 00000000000..1b543fd40ad --- /dev/null +++ b/auth_signup_verify_email/__openerp__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Verify email at signup", + "summary": "Force uninvited users to use a good email for signup", + "version": "8.0.1.0.0", + "category": "Authentication", + "website": "https://odoo-community.org/", + "author": "Antiun Ingeniería, S.L., Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "external_dependencies": { + "python": [ + "validate_email", + ], + }, + "depends": [ + "auth_signup", + ], + "data": [ + "views/signup.xml", + ], +} diff --git a/auth_signup_verify_email/controllers/__init__.py b/auth_signup_verify_email/controllers/__init__.py new file mode 100644 index 00000000000..d10129bede5 --- /dev/null +++ b/auth_signup_verify_email/controllers/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import main diff --git a/auth_signup_verify_email/controllers/main.py b/auth_signup_verify_email/controllers/main.py new file mode 100644 index 00000000000..137c275ee90 --- /dev/null +++ b/auth_signup_verify_email/controllers/main.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import logging +from openerp import _, http +from openerp.addons.auth_signup.controllers.main import AuthSignupHome + + +_logger = logging.getLogger(__name__) + + +class SignupVerifyEmail(AuthSignupHome): + @http.route() + def web_auth_signup(self, *args, **kw): + if (http.request.params.get("login") and + not http.request.params.get("password")): + return self.passwordless_signup(http.request.params) + else: + return super(SignupVerifyEmail, self).web_auth_signup(*args, **kw) + + def passwordless_signup(self, values): + qcontext = self.get_auth_signup_qcontext() + + # Check good format of e-mail + from validate_email import validate_email + if not validate_email(values.get("login", "")): + qcontext["error"] = _("That does not seem to be an email address.") + return http.request.render("auth_signup.signup", qcontext) + elif not values.get("email"): + values["email"] = values.get("login") + + # Remove password + values["password"] = False + sudo_users = (http.request.env["res.users"] + .with_context(create_user=True).sudo()) + + try: + sudo_users.signup(values, qcontext.get("token")) + sudo_users.reset_password(values.get("login")) + except Exception as error: + # Duplicate key or wrong SMTP settings, probably + _logger.exception(error) + http.request.env.cr.rollback() + + # Agnostic message for security + qcontext["error"] = _( + "Something went wrong, please try again later or contact us.") + return http.request.render("auth_signup.signup", qcontext) + + qcontext["message"] = _("Check your email to activate your account!") + return http.request.render("auth_signup.reset_password", qcontext) diff --git a/auth_signup_verify_email/static/description/icon.png b/auth_signup_verify_email/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..52e1b17dcb661d98f613efecf525de26b26fe8c6 GIT binary patch literal 10549 zcmV-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!6&_8sroxZbOI2sQU@pz>Gggs@|G?kW3xWS0g07jsS@xnfLBqzT;(p z#xCm8#k|tx>B{#-==Ca*8U-k<9)M20P25# z27qMkKAAh`mh)!5JywtT;|97%UZ6;w&ba6_hCaLJ!`m7ly=C;~3b}z+{y@5MwC~d| zopvsUe&IF;8v0))3a34QeKGXa=4VEn0;pO)tEVJ?6ObFIx~4rj4}e!@e|)XiZvNU! znEkE~>rC_)*17P86aTnMrj=FnUB7;v_n}>U>}=Qn*2}DElP-jcl9P-KucSM^r>QDh z=e3z%-hKOyb7`ttLd_R8zU$Yn@jkU~>N@bbO|M&L!wrYF4O zSBs}EX&JX~;h9P2X1y|f3c!8p=KQ=XHuvxp0ID|5{MxitbMMZc^hF(@{AWvVPR_d$ zPky?DncHUc$wn%EvH0f1+_al^({9>LyJ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + + 2007-02-06T06:13:53 + Thumbtack note with message "E-mail!" + https://openclipart.org/detail/3040/thumbtack-note-email-by-zeimusu + + + zeimusu + + + + + bulletin + email + memo + note + thumbtack + thumbtack note + + + + + + + + + + + diff --git a/auth_signup_verify_email/views/signup.xml b/auth_signup_verify_email/views/signup.xml new file mode 100644 index 00000000000..a0a13ae608d --- /dev/null +++ b/auth_signup_verify_email/views/signup.xml @@ -0,0 +1,20 @@ + + + + + + + + From 29b71b5cac83c830dd8c460c78cfe37cb182fa40 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 28 Oct 2015 16:51:59 +0100 Subject: [PATCH 02/10] Import module following guidelines. --- auth_signup_verify_email/controllers/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auth_signup_verify_email/controllers/main.py b/auth_signup_verify_email/controllers/main.py index 137c275ee90..01e0474b7a2 100644 --- a/auth_signup_verify_email/controllers/main.py +++ b/auth_signup_verify_email/controllers/main.py @@ -6,9 +6,13 @@ from openerp import _, http from openerp.addons.auth_signup.controllers.main import AuthSignupHome - _logger = logging.getLogger(__name__) +try: + from validate_email import validate_email +except ImportError: + _logger.debug("Cannot import `validate_email`.") + class SignupVerifyEmail(AuthSignupHome): @http.route() @@ -23,7 +27,6 @@ def passwordless_signup(self, values): qcontext = self.get_auth_signup_qcontext() # Check good format of e-mail - from validate_email import validate_email if not validate_email(values.get("login", "")): qcontext["error"] = _("That does not seem to be an email address.") return http.request.render("auth_signup.signup", qcontext) From 41b51bef1cd1e33351827a6968f59784f0bd42af Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 30 Oct 2015 17:33:59 +0100 Subject: [PATCH 03/10] README typos. --- auth_signup_verify_email/README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/auth_signup_verify_email/README.rst b/auth_signup_verify_email/README.rst index 324821b31c1..8ab62eaaf37 100644 --- a/auth_signup_verify_email/README.rst +++ b/auth_signup_verify_email/README.rst @@ -6,10 +6,10 @@ Verify email at signup ====================== -This module was written to extend the functionality of public sign up to force -users to provide a valid email address. +This module extends the functionality of public sign up, and forces users to +provide a valid email address. -To reinforce this requirement, the user will not need to provide a password at +To achieve this requirement, the user does not need to provide a password at sign up, but when logging in later for the first time. Installation @@ -37,7 +37,7 @@ To use this module, you need to: .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/186/8.0 + :target: https://runbot.odoo-community.org/runbot/149/8.0 Bug Tracker =========== From 5ea0130fc90a16922e2e67bc227457fa534fc43c Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 30 Nov 2015 15:14:54 -0500 Subject: [PATCH 04/10] OCA Transbot updated translations from Transifex --- auth_signup_verify_email/i18n/de.po | 47 +++++++++++++++++++++++++ auth_signup_verify_email/i18n/es.po | 48 ++++++++++++++++++++++++++ auth_signup_verify_email/i18n/it.po | 47 +++++++++++++++++++++++++ auth_signup_verify_email/i18n/pt_BR.po | 46 ++++++++++++++++++++++++ auth_signup_verify_email/i18n/sl.po | 47 +++++++++++++++++++++++++ auth_signup_verify_email/i18n/tr.po | 47 +++++++++++++++++++++++++ 6 files changed, 282 insertions(+) create mode 100644 auth_signup_verify_email/i18n/de.po create mode 100644 auth_signup_verify_email/i18n/es.po create mode 100644 auth_signup_verify_email/i18n/it.po create mode 100644 auth_signup_verify_email/i18n/pt_BR.po create mode 100644 auth_signup_verify_email/i18n/sl.po create mode 100644 auth_signup_verify_email/i18n/tr.po diff --git a/auth_signup_verify_email/i18n/de.po b/auth_signup_verify_email/i18n/de.po new file mode 100644 index 00000000000..367716b4016 --- /dev/null +++ b/auth_signup_verify_email/i18n/de.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +# Rudolf Schnapka , 2016 +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-19 14:44+0000\n" +"PO-Revision-Date: 2016-01-18 13:24+0000\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: German (http://www.transifex.com/oca/OCA-server-tools-8-0/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "Prüfen Sie Ihre Email, um Ihr Konto zu aktivieren." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "Etwas ist schief gelaufen, bitte später nochmal versuchen oden an uns wenden." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "Das schein keine Email-Adresse zu sein." + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "EMail" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "" diff --git a/auth_signup_verify_email/i18n/es.po b/auth_signup_verify_email/i18n/es.po new file mode 100644 index 00000000000..c170d4fc5cd --- /dev/null +++ b/auth_signup_verify_email/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +# Antonio Trueba, 2016 +# Antonio Trueba, 2016 +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-19 14:44+0000\n" +"PO-Revision-Date: 2016-02-16 15:15+0000\n" +"Last-Translator: Antonio Trueba\n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-server-tools-8-0/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "Revise su correo para activar su cuenta." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "Algo ha ido mal, por favor inténtelo de nuevo más tarde o contáctenos." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "Eso no parece una dirección de email válida." + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "email" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "" diff --git a/auth_signup_verify_email/i18n/it.po b/auth_signup_verify_email/i18n/it.po new file mode 100644 index 00000000000..75bd3e908e3 --- /dev/null +++ b/auth_signup_verify_email/i18n/it.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +# Paolo Valier, 2016 +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-03-17 15:36+0000\n" +"PO-Revision-Date: 2016-03-13 08:59+0000\n" +"Last-Translator: Paolo Valier\n" +"Language-Team: Italian (http://www.transifex.com/oca/OCA-server-tools-8-0/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "Controlla la tua email per attivare il tuo account!" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "Qualcosa non è funzionato, prego provare più tardi altrimenti mettiti in contatto con noi." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "Questo non sembra essere un indirizzo email valido." + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "email" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "" diff --git a/auth_signup_verify_email/i18n/pt_BR.po b/auth_signup_verify_email/i18n/pt_BR.po new file mode 100644 index 00000000000..1a9ead1bb1c --- /dev/null +++ b/auth_signup_verify_email/i18n/pt_BR.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-27 14:01+0000\n" +"PO-Revision-Date: 2015-11-12 20:16+0000\n" +"Last-Translator: <>\n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-server-tools-8-0/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "email" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "" diff --git a/auth_signup_verify_email/i18n/sl.po b/auth_signup_verify_email/i18n/sl.po new file mode 100644 index 00000000000..612e35cc63c --- /dev/null +++ b/auth_signup_verify_email/i18n/sl.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +# Matjaž Mozetič , 2015 +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-27 14:01+0000\n" +"PO-Revision-Date: 2015-11-13 11:44+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-server-tools-8-0/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "Preverite svojo e-pošto za aktiviranje računa!" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "Nekaj je narobe. Ponovno poskusite kasneje ali pa stopite v stik z nami." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "Kaže, da to ni e-poštni naslov." + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "e-pošta" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "only_passwords" diff --git a/auth_signup_verify_email/i18n/tr.po b/auth_signup_verify_email/i18n/tr.po new file mode 100644 index 00000000000..a41abef839e --- /dev/null +++ b/auth_signup_verify_email/i18n/tr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_signup_verify_email +# +# Translators: +# Ahmet Altınışık , 2016 +msgid "" +msgstr "" +"Project-Id-Version: server-tools (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-19 14:44+0000\n" +"PO-Revision-Date: 2016-01-31 14:58+0000\n" +"Last-Translator: Ahmet Altınışık \n" +"Language-Team: Turkish (http://www.transifex.com/oca/OCA-server-tools-8-0/language/tr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: tr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:54 +#, python-format +msgid "Check your email to activate your account!" +msgstr "Hesabınızı aktive etmek için e-postanızı kontrol edin!" + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:50 +#, python-format +msgid "Something went wrong, please try again later or contact us." +msgstr "Bişeyler ters gitti. Lütfen sonra tekrar deneyin ya da bize ulaşın." + +#. module: auth_signup_verify_email +#: code:addons/auth_signup_verify_email/controllers/main.py:31 +#, python-format +msgid "That does not seem to be an email address." +msgstr "Bu bir e-posta adresi gözükmüyor." + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "email" +msgstr "eposta" + +#. module: auth_signup_verify_email +#: view:website:auth_signup.fields +msgid "only_passwords" +msgstr "sadece_parolalar" From 9d3db4118b9d29fa5da2deb22958c960328aa80c Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 23 Nov 2015 15:58:27 +0100 Subject: [PATCH 05/10] Credit creator. --- auth_signup_verify_email/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth_signup_verify_email/__openerp__.py b/auth_signup_verify_email/__openerp__.py index 1b543fd40ad..c695b61a3c3 100644 --- a/auth_signup_verify_email/__openerp__.py +++ b/auth_signup_verify_email/__openerp__.py @@ -6,7 +6,7 @@ "summary": "Force uninvited users to use a good email for signup", "version": "8.0.1.0.0", "category": "Authentication", - "website": "https://odoo-community.org/", + "website": "http://www.antiun.com", "author": "Antiun Ingeniería, S.L., Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, From b18484ce055e18f7f8f9b6ee672294d1c3d00ac2 Mon Sep 17 00:00:00 2001 From: Rafael Blasco Date: Mon, 4 Jan 2016 17:38:23 +0100 Subject: [PATCH 06/10] author name correction --- auth_signup_verify_email/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth_signup_verify_email/__openerp__.py b/auth_signup_verify_email/__openerp__.py index c695b61a3c3..e349cc7fd59 100644 --- a/auth_signup_verify_email/__openerp__.py +++ b/auth_signup_verify_email/__openerp__.py @@ -7,7 +7,7 @@ "version": "8.0.1.0.0", "category": "Authentication", "website": "http://www.antiun.com", - "author": "Antiun Ingeniería, S.L., Odoo Community Association (OCA)", + "author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, From d6859998b2dfd7c44559afcdb2e8058e673fd57b Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 26 May 2016 16:54:47 +0200 Subject: [PATCH 07/10] [9.0][MIG][auth_signup_verify_email] Migration. Migrate to v9. --- auth_signup_verify_email/README.rst | 17 +++++++---------- auth_signup_verify_email/__openerp__.py | 6 ++++-- auth_signup_verify_email/controllers/main.py | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/auth_signup_verify_email/README.rst b/auth_signup_verify_email/README.rst index 8ab62eaaf37..bba72d65f7c 100644 --- a/auth_signup_verify_email/README.rst +++ b/auth_signup_verify_email/README.rst @@ -24,7 +24,7 @@ To configure this module, you need to: * `Properly configure your outgoing email server(s) `_. -* Go to *Settings > Configuration > General Settings* and enable *Allow +* Go to *Settings > General Settings* and enable *Allow external users to sign up*. Usage @@ -37,18 +37,15 @@ To use this module, you need to: .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/8.0 + :target: https://runbot.odoo-community.org/runbot/149/9.0 Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. - -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and -welcomed feedback `here `_. +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. Credits @@ -79,6 +76,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. .. _validate_email: https://pypi.python.org/pypi/validate_email diff --git a/auth_signup_verify_email/__openerp__.py b/auth_signup_verify_email/__openerp__.py index e349cc7fd59..ba8a9838737 100644 --- a/auth_signup_verify_email/__openerp__.py +++ b/auth_signup_verify_email/__openerp__.py @@ -4,10 +4,12 @@ { "name": "Verify email at signup", "summary": "Force uninvited users to use a good email for signup", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "category": "Authentication", "website": "http://www.antiun.com", - "author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", + "author": "Antiun Ingeniería S.L., " + "Tecnativa, " + "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, diff --git a/auth_signup_verify_email/controllers/main.py b/auth_signup_verify_email/controllers/main.py index 01e0474b7a2..506e9374448 100644 --- a/auth_signup_verify_email/controllers/main.py +++ b/auth_signup_verify_email/controllers/main.py @@ -39,12 +39,12 @@ def passwordless_signup(self, values): .with_context(create_user=True).sudo()) try: - sudo_users.signup(values, qcontext.get("token")) - sudo_users.reset_password(values.get("login")) + with http.request.cr.savepoint(): + sudo_users.signup(values, qcontext.get("token")) + sudo_users.reset_password(values.get("login")) except Exception as error: # Duplicate key or wrong SMTP settings, probably _logger.exception(error) - http.request.env.cr.rollback() # Agnostic message for security qcontext["error"] = _( From 33a156d48e1a671d55ef84d7f3919f9f5f235ba0 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 27 May 2016 09:47:25 +0200 Subject: [PATCH 08/10] [FIX] auth_signup_verify_email: Python library requirement --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d40cb3d3321..c8cb7e172c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ python-ldap unidecode acme_tiny IPy +validate_email From 1ce88c2a2300653fdf1f784c088814293999d49e Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 27 May 2016 13:38:15 +0200 Subject: [PATCH 09/10] Add tests, fix xml tags, fix credits. --- auth_signup_verify_email/__openerp__.py | 3 +- auth_signup_verify_email/tests/__init__.py | 5 ++ .../tests/test_verify_email.py | 59 +++++++++++++++++++ auth_signup_verify_email/views/signup.xml | 8 +-- 4 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 auth_signup_verify_email/tests/__init__.py create mode 100644 auth_signup_verify_email/tests/test_verify_email.py diff --git a/auth_signup_verify_email/__openerp__.py b/auth_signup_verify_email/__openerp__.py index ba8a9838737..6ac75954b69 100644 --- a/auth_signup_verify_email/__openerp__.py +++ b/auth_signup_verify_email/__openerp__.py @@ -6,7 +6,7 @@ "summary": "Force uninvited users to use a good email for signup", "version": "9.0.1.0.0", "category": "Authentication", - "website": "http://www.antiun.com", + "website": "http://www.tecnativa.com", "author": "Antiun Ingeniería S.L., " "Tecnativa, " "Odoo Community Association (OCA)", @@ -15,6 +15,7 @@ "installable": True, "external_dependencies": { "python": [ + "lxml", "validate_email", ], }, diff --git a/auth_signup_verify_email/tests/__init__.py b/auth_signup_verify_email/tests/__init__.py new file mode 100644 index 00000000000..8858be49662 --- /dev/null +++ b/auth_signup_verify_email/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_verify_email diff --git a/auth_signup_verify_email/tests/test_verify_email.py b/auth_signup_verify_email/tests/test_verify_email.py new file mode 100644 index 00000000000..29ce113dc41 --- /dev/null +++ b/auth_signup_verify_email/tests/test_verify_email.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# © 2016 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from urllib import urlencode +from lxml.html import document_fromstring +from openerp import _ +from openerp.tests.common import HttpCase + + +class UICase(HttpCase): + def setUp(self): + super(UICase, self).setUp() + settings = self.env["base.config.settings"].create({}) + settings.auth_signup_uninvited = True + self.data = { + "csrf_token": self.csrf_token(), + "name": "Somebody", + } + self.msg = { + "badmail": _("That does not seem to be an email address."), + "failure": _( + "Something went wrong, please try again later or contact us."), + "success": _("Check your email to activate your account!"), + } + + def html_doc(self, url="/web/signup", data=None, timeout=10): + """Get an HTML LXML document.""" + if data: + data = bytes(urlencode(data)) + return document_fromstring(self.url_open(url, data, timeout).read()) + + def csrf_token(self): + """Get a valid CSRF token.""" + doc = self.html_doc() + return doc.xpath("//input[@name='csrf_token']")[0].get("value") + + def search_text(self, doc, text): + """Search for any element containing the text.""" + return doc.xpath("//*[contains(text(), '%s')]" % text) + + def test_bad_email(self): + """Test rejection of bad emails.""" + self.data["login"] = "bad email" + doc = self.html_doc(data=self.data) + self.assertTrue(self.search_text(doc, self.msg["badmail"])) + + def test_good_email(self): + """Test acceptance of good emails. + + This test could lead to success if your SMTP settings are correct, or + to failure otherwise. Any case is expected, since tests usually run + under unconfigured demo instances. + """ + self.data["login"] = "good@example.com" + doc = self.html_doc(data=self.data) + self.assertTrue( + self.search_text(doc, self.msg["failure"]) or + self.search_text(doc, self.msg["success"])) diff --git a/auth_signup_verify_email/views/signup.xml b/auth_signup_verify_email/views/signup.xml index a0a13ae608d..cc81fcccf21 100644 --- a/auth_signup_verify_email/views/signup.xml +++ b/auth_signup_verify_email/views/signup.xml @@ -1,6 +1,7 @@ - - + + - - + From 48842f36ea1d4ba99bb14d34f9fc572b5af6d7a8 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 31 May 2016 10:35:01 +0200 Subject: [PATCH 10/10] Fix test. --- auth_signup_verify_email/README.rst | 6 ++++++ .../tests/test_verify_email.py | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/auth_signup_verify_email/README.rst b/auth_signup_verify_email/README.rst index bba72d65f7c..041de578ee3 100644 --- a/auth_signup_verify_email/README.rst +++ b/auth_signup_verify_email/README.rst @@ -39,6 +39,12 @@ To use this module, you need to: :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/149/9.0 +Known issues / Roadmap +====================== + +* Remove calls to ``cr.commit()`` in tests when + https://github.com/odoo/odoo/issues/12237 gets fixed. + Bug Tracker =========== diff --git a/auth_signup_verify_email/tests/test_verify_email.py b/auth_signup_verify_email/tests/test_verify_email.py index 29ce113dc41..a3649cd7dea 100644 --- a/auth_signup_verify_email/tests/test_verify_email.py +++ b/auth_signup_verify_email/tests/test_verify_email.py @@ -11,8 +11,14 @@ class UICase(HttpCase): def setUp(self): super(UICase, self).setUp() - settings = self.env["base.config.settings"].create({}) - settings.auth_signup_uninvited = True + self.icp = self.env["ir.config_parameter"] + self.old_allow_uninvited = self.icp.get_param( + "auth_signup.allow_uninvited") + self.icp.set_param("auth_signup.allow_uninvited", "True") + + # Workaround https://github.com/odoo/odoo/issues/12237 + self.cr.commit() + self.data = { "csrf_token": self.csrf_token(), "name": "Somebody", @@ -24,6 +30,13 @@ def setUp(self): "success": _("Check your email to activate your account!"), } + def tearDown(self): + """Workaround https://github.com/odoo/odoo/issues/12237.""" + super(UICase, self).tearDown() + self.icp.set_param( + "auth_signup.allow_uninvited", self.old_allow_uninvited) + self.cr.commit() + def html_doc(self, url="/web/signup", data=None, timeout=10): """Get an HTML LXML document.""" if data: