Commits

Dominik Ruf  committed af18d5f

create new user account if there isn't one yet or connect account with matching email

  • Participants
  • Parent commits 346c70f

Comments (0)

Files changed (1)

File plonesocial/auth/rpx/plugins/rpx.py

                             self.REQUEST.RESPONSE, login, "")
                 return (user_id, login)
             else:
-                logger.error("RPX authentication failed for %s" % login)
+                user_id = login = credentials.get('email')
+                member = ms_tool.getMemberById(login)
+                if not member:
+                    pr_tool = getToolByName(self, 'portal_registration')
+                    import random, string
+                    pr_tool.addMember(login, ''.join([random.choice(string.letters + string.digits) for i in range(8)]))
+                    member = ms_tool.getMemberById(login)
+                    credentials['fullname'] = credentials['name']['formatted']
+                    
+                self._getPAS().updateCredentials(self.REQUEST, self.REQUEST.RESPONSE, login, "")
+                rpx_ids = list(member.getProperty('rpx_identifier'))
+                rpx_ids.append(credentials['identifier'])
+                credentials['rpx_identifier'] = rpx_ids
+                credentials['home_page'] = credentials.get('url', '')
+                member.setMemberProperties(credentials)
+                
+                return (user_id, login)
         return None