def getUserId(self): """ Return the user id """ relationship = UserRelatedRelation.relationship user_providers = self.context.getBRefs(relationship=relationship) if user_providers: assert len(user_providers) == 1 user_provider = IUserAuthProvider(user_providers[0]) return IMembraneUserObject(user_provider).getUserId() else: try: user_provider = IUserAuthProvider(self.context) return IMembraneUserObject(user_provider).getUserId() except TypeError: return None
def reindex(self, obj, attributes=[]): if IMembraneUserObject(obj, None) is None and IGroup(obj, None) is None: return mbtool = getToolByName(obj, 'membrane_tool', None) if mbtool is not None: if getattr(obj, 'portal_type') in mbtool.listMembraneTypes(): mbtool.reindexObject(obj, attributes or [])
def index(self, obj, attributes=[]): if IMembraneUserObject(obj, None) is None and IGroup(obj, None) is None: return mbtool = getToolByName(obj, "membrane_tool", None) if mbtool is not None: # Verify that the portal_type is part of the catalog map if getattr(obj, 'portal_type') in mbtool.listMembraneTypes(): mbtool.indexObject(obj, attributes or [])
def unindex(self, obj): wrapped_obj = obj if aq_base(obj).__class__.__name__ == 'PathWrapper': # Could be a PathWrapper object from collective.indexing. obj = obj.context if IMembraneUserObject(obj, None) is None and IGroup(obj, None) is None: return mbtool = getToolByName(obj, 'membrane_tool', None) if mbtool is not None: if getattr(obj, 'portal_type') in mbtool.listMembraneTypes(): mbtool.unindexObject(wrapped_obj)
def unindex(self, obj): wrapped_obj = obj if isinstance(obj, PathProxy): # Could be a PathProxy object from CMFCore.indexing obj = getProxiedObject(obj) if IMembraneUserObject(obj, None) is None and IGroup(obj, None) is None: return mbtool = getToolByName(obj, 'membrane_tool', None) if mbtool is not None: if getattr(obj, 'portal_type') in mbtool.listMembraneTypes(): mbtool.unindexObject(wrapped_obj)
def authenticateCredentials(self, credentials): login = credentials.get('login') password = credentials.get('password') if login is None or password is None: return None # Adapt to IUserAuthentication to provide the actual authentication. # If no such adapter (or null-adapter) exists, fail. authentication = IUserAuthentication(self.context, None) if authentication is None: return None if authentication.verifyCredentials(credentials): info = IMembraneUserObject(self.context, self) userid = info.getUserId() return userid, login
def getUserId(obj): obj = IMembraneUserObject(obj, None) if obj is None: return None return obj.getUserId()