Commit 24ba1506 authored by Julien Muchembled's avatar Julien Muchembled

Fix removal of reference on persons

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39724 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f345c95e
...@@ -170,10 +170,11 @@ class Person(EncryptedPasswordMixin, XMLObject): ...@@ -170,10 +170,11 @@ class Person(EncryptedPasswordMixin, XMLObject):
- we want to prevent duplicated user ids, but only when - we want to prevent duplicated user ids, but only when
PAS _AND_ ERP5UserManager are used PAS _AND_ ERP5UserManager are used
""" """
activate_kw = {}
if value: if value:
# Encode reference to hex to prevent uppercase/lowercase conflict in # Encode reference to hex to prevent uppercase/lowercase conflict in
# activity table (when calling countMessageWithTag) # activity table (when calling countMessageWithTag)
tag = 'Person_setReference_%s' % value.encode('hex') activate_kw['tag'] = tag = 'Person_setReference_' + value.encode('hex')
# Check that there no existing user # Check that there no existing user
acl_users = getToolByName(self, 'acl_users') acl_users = getToolByName(self, 'acl_users')
if PluggableAuthService is not None and isinstance(acl_users, if PluggableAuthService is not None and isinstance(acl_users,
...@@ -203,11 +204,9 @@ class Person(EncryptedPasswordMixin, XMLObject): ...@@ -203,11 +204,9 @@ class Person(EncryptedPasswordMixin, XMLObject):
raise RuntimeError, 'user id %s already exist' % (value,) raise RuntimeError, 'user id %s already exist' % (value,)
else: else:
transactional_variable[tag] = None transactional_variable[tag] = None
else:
tag = None
self._setReference(value) self._setReference(value)
self.reindexObject(activate_kw={'tag': tag}) self.reindexObject(activate_kw=activate_kw)
# invalid the cache for ERP5Security # invalid the cache for ERP5Security
portal_caches = getToolByName(self.getPortalObject(), 'portal_caches') portal_caches = getToolByName(self.getPortalObject(), 'portal_caches')
portal_caches.clearCache(cache_factory_list=('erp5_content_short', )) portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
......
...@@ -404,8 +404,8 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -404,8 +404,8 @@ class TestUserManagement(ERP5TypeTestCase):
def test_PersonLoginIsPossibleToUnset(self): def test_PersonLoginIsPossibleToUnset(self):
"""Make sure that it is possible to remove reference""" """Make sure that it is possible to remove reference"""
p = self._makePerson(reference='foo', password='secret',) person = self._makePerson(reference='foo', password='secret',)
p.setReference(None) person.setReference(None)
transaction.commit() transaction.commit()
self.tic() self.tic()
self.assertEqual(None, person.getReference()) self.assertEqual(None, person.getReference())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment