def test_user_activation(self):
        login(self.portal, testing.SITE_ADMIN)

        members = self.portal['people']

        # create a user:
        member = utilities.add_member_object(members, member_id='member',
            fullname=u"Hörbert M@ier", email="*****@*****.**")

        logout()

        password = '******'
        utilities.add_plone_member(member, password)
        utilities.activate_member_object(member)

        plone_member = self.portal.acl_users.authenticate(member.id, password,
            self.portal.REQUEST)
        self.assertNotEqual(plone_member, None)

        portal_membership = getToolByName(self.portal, 'portal_membership')
        plone_member = portal_membership.getMemberById(member.id)
        self.assertNotEqual(plone_member, None)

        self.assertEqual(unicode(plone_member.getProperty('fullname'), 'utf-8'),
            member.title)
        self.assertEqual(plone_member.getProperty('email'), member.emailAddress)

        login(self.portal, member.id)
    def test_user_activation(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # create a user:
        member = utilities.add_member_object(members, member_id='member',
            fullname=u"Hörbert M@ier", email="*****@*****.**")

        logout()

        password = '******'
        utilities.add_plone_member(member, 'secret')
        utilities.activate_member_object(member)

        plone_member = self.portal.acl_users.authenticate(member.id, password,
            self.portal.REQUEST)
        self.assertEqual(plone_member.getId(), member.id)

        portal_membership = getToolByName(self.portal, 'portal_membership')
        plone_member = portal_membership.getMemberById(member.id)
        self.assertEqual(plone_member.getId(), member.id)

        self.assertEqual(unicode(plone_member.getProperty('fullname'), 'utf-8'),
            member.title)
        self.assertEqual(plone_member.getProperty('email'), member.emailAddress)

        login(self.portal, member.id)
Example #3
0
def add_activated_cnrd_member(people_folder, name, role, uid=None, email=None,
                              password='******'):
    if uid is None:
        uid = utilities.find_possible_id(name)
    if email is None:
        email = uid + "@testing.ixds.com"
    member = covalent_utils.add_member_object(people_folder, uid, name, email)
    member.role = role
    modified(member)
    covalent_utils.add_plone_member(member, password)
    covalent_utils.activate_member_object(member)
    return member
Example #4
0
def add_cnrd_member(site, userId, last, first, email, password, portrait=None):
    context = site["people"]

    if userId in context:
        print "Couldn't add %s, a vc-member with this id already exists." % (id)
        return

    member_obj = add_member_object(context, userId, u"%s %s" % (first, last), email.strip(), sendInvitation=False)
    add_plone_member(member_obj, password)
    activate_member_object(member_obj)
    mark(context[userId], IDemoContent)

    if portrait:
        context[userId].portrait = portrait

    context[userId].role = "student"

    notify(ObjectModifiedEvent(context[userId]))
Example #5
0
    def completeHandler(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        if not (self.activation_code_valid and self.terms_accepted):
            return

        utilities.add_plone_member(self.context, data['password'])
        utilities.activate_member_object(self.context)

        # log in as the newly activated member:
        acl_users = getToolByName(self.context, 'acl_users')
        acl_users.session._setupSession(self.context.id, self.request.response)

        intids = getUtility(IIntIds)
        welcomePage = intids.getObject(self.context.aq_parent.welcomePage.to_id)
        self.request.response.redirect(welcomePage.absolute_url())
    def test_user_role_assignments(self):
        login(self.portal, testing.SITE_ADMIN)
        members = self.portal['people']
        member = utilities.add_member_object(members, member_id='member',
            fullname=u"Hörbert M@ier", email="*****@*****.**")
        logout()
        password = '******'
        utilities.add_plone_member(member, password)
        utilities.activate_member_object(member)

        self.assertEqual(getattr(member, 'role', None), None)
        groups = get_group_ids_by_user_id(self.portal, member.id)
        self.assertEqual(groups, ['AuthenticatedUsers'])
        roles = get_roles_by_user_id(self.portal, member.id)
        self.assertEqual(roles, ['Authenticated'])

        member.role = 'student'
        modified(member)
        groups = get_group_ids_by_user_id(self.portal, member.id)
        self.assertEqual(groups, ['AuthenticatedUsers', 'Students'])
        roles = get_roles_by_user_id(self.portal, member.id)
        self.assertEqual(roles, ['Authenticated', 'Member', 'Student'])

        member.role = 'teacher'
        modified(member)
        groups = get_group_ids_by_user_id(self.portal, member.id)
        self.assertEqual(groups, ['AuthenticatedUsers', 'Teachers'])
        roles = get_roles_by_user_id(self.portal, member.id)
        self.assertEqual(roles, ['Authenticated', 'Member', 'Teacher'])

        member.role = 'extern'
        modified(member)
        groups = get_group_ids_by_user_id(self.portal, member.id)
        self.assertEqual(groups, ['AuthenticatedUsers', 'Externs'])
        roles = get_roles_by_user_id(self.portal, member.id)
        self.assertEqual(roles, ['Authenticated', 'Extern'])