From a97402d30395929fbde7db1a5f880c10d2420307 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Thu, 17 Dec 2015 15:05:18 +0100
Subject: [PATCH] authentication : do not use countMessage to prevent race
 condition

---
 .../Person_notifyPasswordExpire.xml                       | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/bt5/erp5_authentication_policy/SkinTemplateItem/portal_skins/erp5_authentication_policy/Person_notifyPasswordExpire.xml b/bt5/erp5_authentication_policy/SkinTemplateItem/portal_skins/erp5_authentication_policy/Person_notifyPasswordExpire.xml
index de0d6caa39..7fbb30c792 100644
--- a/bt5/erp5_authentication_policy/SkinTemplateItem/portal_skins/erp5_authentication_policy/Person_notifyPasswordExpire.xml
+++ b/bt5/erp5_authentication_policy/SkinTemplateItem/portal_skins/erp5_authentication_policy/Person_notifyPasswordExpire.xml
@@ -67,11 +67,6 @@ if not portal_preferences.isAuthenticationPolicyEnabled() or \\\n
   # no policy, no sense to file expire at all or symply system do not configured to\n
   return 0\n
 \n
-# Prevent creating 10 recoveries when browser access all HTML, CSS, JS files in parallel\n
-tag = "%s_passwd_recovery_inProgress" % context.getUid()\n
-if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
-  return 0\n
-\n
 # Prevent creating new recovery if one was recently created\n
 recovery_list = portal.portal_catalog(\n
   portal_type="Credential Recovery",\n
@@ -89,6 +84,9 @@ credential_recovery = module.newContent(\n
                                destination_decision_value=context,\n
                                language=portal.Localizer.get_selected_language(),\n
                                activate_kw={\'tag\': tag})\n
+# immediate reindex allowed because it is a new object\n
+credential_recovery.immediateReindexObject()\n
+context.serialize()\n
 credential_recovery.submit()\n
 
 
-- 
2.30.9