From 5c480b0bff7be2ab62cfe78f67c2fe89de7b4654 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 2 Jun 2014 15:44:39 +0200
Subject: [PATCH] credentials: only take into account persons with reference
 when looking up login from email

also simplify some error messages
---
 .../ERP5Site_getRelatedCredentialQuestionDialog.xml      | 9 +++++----
 .../fr/erp5_ui/translation.po                            | 6 +++---
 bt5/erp5_l10n_fr/bt/revision                             | 2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_getRelatedCredentialQuestionDialog.xml b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_getRelatedCredentialQuestionDialog.xml
index 6e29f06a01..5af62ca577 100644
--- a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_getRelatedCredentialQuestionDialog.xml
+++ b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_getRelatedCredentialQuestionDialog.xml
@@ -65,7 +65,7 @@ if choice == "password":\n
   portal_preferences = context.portal_preferences\n
   result = person_module.searchFolder(reference={\'query\': reference, \'key\': \'ExactMatch\'})\n
   if len(result) != 1:\n
-    portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
+    portal_status_message = context.Base_translateString("Could not find your user account.")\n
     if web_site:\n
       return web_site.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
     return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
@@ -96,12 +96,13 @@ if choice == "password":\n
 elif choice == "username":\n
   query_kw = {"email.url_string" : default_email_text}\n
   result = portal.portal_catalog(portal_type="Email", parent_portal_type="Person", **query_kw)\n
-  if len(result) == 0:\n
-    portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
+  person_list = [x.getParentValue() for x in result]\n
+  person_list = [x for x in result if x.getReference()] # only consider persons with a valid login\n
+  if len(person_list) == 0:\n
+    portal_status_message = context.Base_translateString("Could not find your user account.")\n
     if web_site:\n
       return web_site.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
     return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
-  person_list = [x.getParentValue() for x in result]\n
   return context.ERP5Site_newCredentialRecovery(default_email_text=default_email_text, person_list=person_list)\n
 </string> </value>
         </item>
diff --git a/bt5/erp5_l10n_fr/MessageTranslationTemplateItem/fr/erp5_ui/translation.po b/bt5/erp5_l10n_fr/MessageTranslationTemplateItem/fr/erp5_ui/translation.po
index 22e54be743..86fbdeb6b4 100644
--- a/bt5/erp5_l10n_fr/MessageTranslationTemplateItem/fr/erp5_ui/translation.po
+++ b/bt5/erp5_l10n_fr/MessageTranslationTemplateItem/fr/erp5_ui/translation.po
@@ -1659,9 +1659,6 @@ msgstr "Impossible de trouver l'organisation correspondant 脿 votre login, il n'
 msgid "Can't find corresponding person, it's not possible to reset your password."
 msgstr "Impossible de trouver la personne correspondant 脿 votre login, il n'est pas possible de r茅initialiser votre mot de passe."
 
-msgid "Can't find corresponding person, it's not possible to update your credentials."
-msgstr "Impossible de trouver la personne correspondant 脿 votre login, il n'est pas possible de mettre 脿 jour vos informations."
-
 msgid "Cancel"
 msgstr "Annuler"
 
@@ -2661,6 +2658,9 @@ msgstr "D茅nomination sociale"
 msgid "Corporate Registration Code"
 msgstr "SIRET"
 
+msgid "Could not find your user account."
+msgstr "Impossible de trouver votre compte utilisateur."
+
 msgid "Count"
 msgstr "Nombre"
 
diff --git a/bt5/erp5_l10n_fr/bt/revision b/bt5/erp5_l10n_fr/bt/revision
index 0d389107a3..964480f63e 100644
--- a/bt5/erp5_l10n_fr/bt/revision
+++ b/bt5/erp5_l10n_fr/bt/revision
@@ -1 +1 @@
-212
+213
-- 
2.30.9