def __init__(self, userInfo, address): self.userInfo = userInfo self.addr = address.strip() eu = EmailUser(userInfo.user, userInfo) userAddrs = [l.lower() for l in eu.get_addresses()] assert address.lower() in userAddrs, '%s not in %s' % \ (address.lower(), userAddrs)
def get_addrs(self, toAddr): notifiedUser = IGSNotifyUser(self.userInfo) try: addrs = notifiedUser.get_addresses() except AssertionError: addrs = [toAddr.strip()] addrs = [a for a in addrs if a] ### BEGIN(hack) ### TODO: Remove this hack ### ### --=mpj17=-- UGLY HACK --=mpj17=-- ### ### Sometimes a person is invited who has an existing profile ### but all his or her email addresses are unverified. If this ### is the case we will send the invitation anyway. With **luck** ### the user will only have **one** (un, uno, I, 1) address, ### which will get verified when he or she joins. Otherwise the ### gs.profile.invite.initialresponse.InitialResponseForm may ### verify the **wrong** address. ### ### See <https://projects.iopen.net/groupserver/ticket/514> ### if not addrs: eu = EmailUser(self.context, self.userInfo) addrs = eu.get_addresses() ### END(hack) (* Modula-2 Geek *) assert type(addrs) == list,\ 'Returning a %s, rather than a list' % type(addrs) return addrs
def get_addrs(self, toAddr): notifiedUser = IGSNotifyUser(self.userInfo) try: addrs = notifiedUser.get_addresses() except AssertionError: addrs = [toAddr.strip()] addrs = [a for a in addrs if a] ### BEGIN(hack) ### TODO: Remove this hack ### ### --=mpj17=-- UGLY HACK --=mpj17=-- ### ### Sometimes a person is invited who has an existing profile ### but all his or her email addresses are unverified. If this ### is the case we will send the invitation anyway. With **luck** ### the user will only have **one** (un, uno, I, 1) address, ### which will get verified when he or she joins. Otherwise the ### gs.profile.invite.initialresponse.InitialResponseForm may ### verify the **wrong** address. ### ### See <https://projects.iopen.net/groupserver/ticket/514> ### if not addrs: eu = EmailUser(self.context, self.userInfo) addrs = eu.get_addresses() ### END(hack) (* Modula-2 Geek *) assert type(addrs) == list,\ 'Returning a %s, rather than a list' % type(addrs) return addrs
def bounceHistory(self): retval = {} query = BounceHistoryQuery(self.context) eu = EmailUser(self.context, self.userInfo) emailAddresses = eu.get_addresses() for email in emailAddresses: retval[email] = [self.munge_event(e) for e in query.bounce_events(email)] return retval
def verify_email_address(self): # There better be only one email address. emailUser = EmailUser(self.context, self.userInfo) email = emailUser.get_addresses()[0] # Assuming this will work ;) vid = '%s_accept' % self.invitationId eu = EmailVerificationUser(self.groupInfo.groupObj, self.userInfo, email) eu.add_verification_id(vid) eu.verify_email(vid)
def verify_email_address(self): # There better be only one email address. emailUser = EmailUser(self.context, self.userInfo) email = emailUser.get_addresses()[0] # Assuming this will work ;) vid = '%s_accept' % self.invitationId eu = EmailVerificationUser(self.groupInfo.groupObj, self.userInfo, email) eu.add_verification_id(vid) eu.verify_email(vid)
class SetPasswordForm(SiteForm): form_fields = form.Fields(IGSSetPasswordRegister) label = _('set-password-label', 'Set password') pageTemplateFileName = 'browser/templates/setpassword.pt' template = ZopeTwoPageTemplateFile(pageTemplateFileName) def __init__(self, context, request): SiteForm.__init__(self, context, request) self.userInfo = GSUserInfo(context) self.emailUser = EmailUser(context, self.userInfo) @form.action(label=_('set-password-button', 'Set'), name='set', failure='handle_set_action_failure') def handle_set(self, action, data): assert self.context assert self.form_fields assert action assert data pu = IGSPasswordUser(self.userInfo) pu.set_password(data['password1']) userInfo = createObject('groupserver.LoggedInUser', self.context) uri = '%s/registration_profile.html' % userInfo.url cf = str(data.get('came_from')) if cf == 'None': cf = '' gid = str(data.get('groupId')) if gid == 'None': gid = '' uri = '%s?form.joinable_groups:list=%s&form.came_from=%s' %\ (uri, gid, cf) return self.request.RESPONSE.redirect(uri) def handle_set_action_failure(self, action, data, errors): if len(errors) == 1: s = _('single-error', 'There is an error:') else: s = _('multiple-errors', 'There are errors:') self.status = '<p>{0}</p>'.format(s) @property def userEmail(self): retval = self.emailUser.get_addresses() assert retval return retval
class SetPasswordForm(SiteForm): form_fields = form.Fields(IGSSetPasswordRegister) label = _('set-password-label', 'Set password') pageTemplateFileName = 'browser/templates/setpassword.pt' template = ZopeTwoPageTemplateFile(pageTemplateFileName) def __init__(self, context, request): SiteForm.__init__(self, context, request) self.userInfo = GSUserInfo(context) self.emailUser = EmailUser(context, self.userInfo) @form.action(label=_('set-password-button', 'Set'), name='set', failure='handle_set_action_failure') def handle_set(self, action, data): assert self.context assert self.form_fields assert action assert data pu = IGSPasswordUser(self.userInfo) pu.set_password(data['password1']) userInfo = createObject('groupserver.LoggedInUser', self.context) uri = '%s/registration_profile.html' % userInfo.url cf = str(data.get('came_from')) if cf == 'None': cf = '' gid = str(data.get('groupId')) if gid == 'None': gid = '' uri = '%s?form.joinable_groups:list=%s&form.came_from=%s' %\ (uri, gid, cf) return self.request.RESPONSE.redirect(uri) def handle_set_action_failure(self, action, data, errors): if len(errors) == 1: s = _('single-error', 'There is an error:') else: s = _('multiple-errors', 'There are errors:') self.status = '<p>{0}</p>'.format(s) @property def userEmail(self): retval = self.emailUser.get_addresses() assert retval return retval
def __call__(self, context, verificationId): queries = VerificationQuery() s = queries.verificationId_status(verificationId) if s == queries.NOT_FOUND: raise VerificationIdNotFoundError(verificationId) userId = queries.get_userId_from_verificationId(verificationId) aclUsers = context.site_root().acl_users user = aclUsers.getUser(userId) if not user: m = 'No user for the verification ID "{0}"' msg = m.format(verificationId) raise NoUserForVerificationId(msg) userInfo = IGSUserInfo(user) emailUser = EmailUser(context, userInfo) email = queries.get_email_from_verificationId(verificationId) assert email in emailUser.get_addresses(), \ 'Address %s does not belong to %s (%s)' %\ (email, userInfo.name, userInfo.id) return EmailVerificationUser(context, userInfo, email)
def __call__(self, context, verificationId): queries = VerificationQuery() s = queries.verificationId_status(verificationId) if s == queries.NOT_FOUND: raise VerificationIdNotFoundError(verificationId) userId = queries.get_userId_from_verificationId(verificationId) aclUsers = context.site_root().acl_users user = aclUsers.getUser(userId) if not user: m = 'No user for the verification ID "{0}"' msg = m.format(verificationId) raise NoUserForVerificationId(msg) userInfo = IGSUserInfo(user) emailUser = EmailUser(context, userInfo) email = queries.get_email_from_verificationId(verificationId) assert email in emailUser.get_addresses(), \ 'Address %s does not belong to %s (%s)' %\ (email, userInfo.name, userInfo.id) return EmailVerificationUser(context, userInfo, email)