Browse Source

[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
master
Jairo Llopis 6 years ago
committed by Martin Trigaux
parent
commit
5425316eff
  1. 6
      addons/auth_signup/controllers/main.py
  2. 26
      addons/auth_signup/i18n/auth_signup.pot

6
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)

26
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"

Loading…
Cancel
Save