From 4a062898ae723db4755a4c900eb3bc66393f6c48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 5 Jun 2013 00:48:15 +0200 Subject: [PATCH] =?utf8?q?R=C3=A9-impl=C3=A9mentation=20de=20setSecurityPr?= =?utf8?q?ofile=20en=20utilisant=20l'API=20de=20l'acl=5Fusers=20de=20zope.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- MemberDataTool.py | 43 +++++++++++++++++++++++++++++-------------- MembershipTool.py | 40 ++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/MemberDataTool.py b/MemberDataTool.py index 4a432eb..85fc4b2 100755 --- a/MemberDataTool.py +++ b/MemberDataTool.py @@ -40,6 +40,7 @@ from Products.CMFCore.interfaces import IRegistrationTool #from Products.CMFCore.utils import getToolByName from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.CMFCore.DynamicType import DynamicType +from Products.CMFCore.exceptions import BadRequest from utils import formatFullName from permissions import SetMemberProperties, SetMemberPassword @@ -117,10 +118,23 @@ class MemberAdapter(BaseMemberAdapter, SimpleItem, DynamicType, CMFCatalogAware) registration = getUtility(IRegistrationTool) failMessage = registration.testPasswordValidity(password) if failMessage is not None : - raise ValueError(failMessage) + raise BadRequest(failMessage) self.setSecurityProfile(password=password, domains=domains) + security.declarePrivate('setSecurityProfile') + def setSecurityProfile(self, password=None, roles=None, domains=None): + """Set the user's basic security profile""" + u = self.getUser() + # This is really hackish. The Zope User API needs methods + # for performing these functions. + if password is not None: + u.setPassword(password) + if roles is not None: + u.setRoles(roles) + if domains is not None: + u.setDomains(domains) + security.declarePrivate('manage_beforeDelete') def manage_beforeDelete(self) : """ uncatalog object """ @@ -177,20 +191,21 @@ class MemberData (BaseData, DynamicType, CMFCatalogAware): # if user_folder.meta_type == 'Group User Folder' : # self.changePassword(password) - + +#migré #XXX restore the previous implementation for GRUF 2 I'll remove that later... - security.declarePrivate('setSecurityProfile') - def setSecurityProfile(self, password=None, roles=None, domains=None): - """Set the user's basic security profile""" - u = self.getUser() - # This is really hackish. The Zope User API needs methods - # for performing these functions. - if password is not None: - u.__ = password - if roles is not None: - u.roles = roles - if domains is not None: - u.domains = domains +# security.declarePrivate('setSecurityProfile') +# def setSecurityProfile(self, password=None, roles=None, domains=None): +# """Set the user's basic security profile""" +# u = self.getUser() +# # This is really hackish. The Zope User API needs methods +# # for performing these functions. +# if password is not None: +# u.__ = password +# if roles is not None: +# u.roles = roles +# if domains is not None: +# u.domains = domains # migré # def getMemberFullName(self, nameBefore=1) : diff --git a/MembershipTool.py b/MembershipTool.py index d60ed39..0d7624e 100755 --- a/MembershipTool.py +++ b/MembershipTool.py @@ -77,26 +77,26 @@ class MembershipTool( BaseTool ): memberareaPortalType = 'Folder' - security.declareProtected(SetOwnPassword, 'setPassword') - def setPassword(self, password, domains=None): - '''Allows the authenticated member to set his/her own password. - ''' - user_folder = self.__getPUS() - if user_folder.meta_type == 'Group User Folder' : - registration = getToolByName(self, 'portal_registration', None) - if not self.isAnonymousUser(): - member = self.getAuthenticatedMember() - if registration: - failMessage = registration.testPasswordValidity(password) - if failMessage is not None: - raise 'Bad Request', failMessage - member.setSecurityProfile(password=password, domains=domains) - member.changePassword(password) - else: - raise 'Bad Request', 'Not logged in.' - - else : - BaseTool.setPassword(self, password, domains=None) +# security.declareProtected(SetOwnPassword, 'setPassword') +# def setPassword(self, password, domains=None): +# '''Allows the authenticated member to set his/her own password. +# ''' +# user_folder = self.__getPUS() +# if user_folder.meta_type == 'Group User Folder' : +# registration = getToolByName(self, 'portal_registration', None) +# if not self.isAnonymousUser(): +# member = self.getAuthenticatedMember() +# if registration: +# failMessage = registration.testPasswordValidity(password) +# if failMessage is not None: +# raise 'Bad Request', failMessage +# member.setSecurityProfile(password=password, domains=domains) +# member.changePassword(password) +# else: +# raise 'Bad Request', 'Not logged in.' +# +# else : +# BaseTool.setPassword(self, password, domains=None) -- 2.20.1