From 5425316eff19e7ae716aafdb730c92d1b3ea2abb Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 16 Dec 2015 14:16:20 +0100 Subject: [PATCH] [FIX] auth_signup: no SQL error for duplicated user In case of registration with an already existant user, an SQL error 'duplicate key value violates unique constaint res_users_login_key...' Replace by a more user friendly error. Fixes #10068, opw 659913 --- addons/auth_signup/controllers/main.py | 6 +++++- addons/auth_signup/i18n/auth_signup.pot | 26 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 91326d5d530..7678db52198 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -54,7 +54,11 @@ class AuthSignupHome(openerp.addons.web.controllers.main.Home): self.do_signup(qcontext) return super(AuthSignupHome, self).web_login(*args, **kw) except (SignupError, AssertionError), e: - qcontext['error'] = _(e.message) + if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]): + qcontext["error"] = _("Another user is already registered using this email address.") + else: + _logger.error(e.message) + qcontext['error'] = _("Could not create a new account.") return request.render('auth_signup.signup', qcontext) diff --git a/addons/auth_signup/i18n/auth_signup.pot b/addons/auth_signup/i18n/auth_signup.pot index a635a4ac086..ba66c98cbdb 100644 --- a/addons/auth_signup/i18n/auth_signup.pot +++ b/addons/auth_signup/i18n/auth_signup.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-01-21 14:07+0000\n" -"PO-Revision-Date: 2015-01-21 14:07+0000\n" +"POT-Creation-Date: 2015-12-16 13:15+0000\n" +"PO-Revision-Date: 2015-12-16 13:15+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -86,7 +86,13 @@ msgid "An invitation email containing the following subscription link has been s msgstr "" #. module: auth_signup -#: code:addons/auth_signup/controllers/main.py:125 +#: code:addons/auth_signup/controllers/main.py:58 +#, python-format +msgid "Another user is already registered using this email address." +msgstr "" + +#. module: auth_signup +#: code:addons/auth_signup/controllers/main.py:130 #, python-format msgid "Authentification Failed." msgstr "" @@ -109,7 +115,13 @@ msgid "Confirm Password" msgstr "" #. module: auth_signup -#: code:addons/auth_signup/controllers/main.py:80 +#: code:addons/auth_signup/controllers/main.py:61 +#, python-format +msgid "Could not create a new account." +msgstr "" + +#. module: auth_signup +#: code:addons/auth_signup/controllers/main.py:84 #, python-format msgid "Could not reset your password" msgstr "" @@ -160,6 +172,12 @@ msgstr "" msgid "Reset password" msgstr "" +#. module: auth_signup +#: code:addons/auth_signup/res_users.py:267 +#, python-format +msgid "Reset password: invalid username or email" +msgstr "" + #. module: auth_signup #: view:res.users:auth_signup.res_users_form_view msgid "Send Reset Password Instructions"