Commit 523dedbd authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_base: Upgrade login to Facebook/Google login when applicable.

parent 5f4ceb1d
def migrateToERP5Login(self): def migrateToERP5Login(self):
assert self.getPortalType() == 'Person' assert self.getPortalType() == 'Person'
login_portal_type = 'ERP5 Login'
reference = self.getReference() reference = self.getReference()
if not reference: if not reference:
# no user id and no login is required # no user id and no login is required
return return
if not self.hasUserId() or self.getUserId() == reference:
if not (self.hasUserId() or self.getUserId() == reference):
self._baseSetUserId(reference) self._baseSetUserId(reference)
self.reindexObject() self.reindexObject()
if not self.hasPassword():
# no login is required, but possibly another Login type object is required if implemented if reference.startswith("go_"):
return login_portal_type = "Google Login"
if len(self.objectValues(portal_type=self.getPortalObject().getPortalLoginTypeList())): reference = self.getDefaultEmailText()
elif reference.startswith("fb_"):
login_portal_type = "Facebook Login"
reference = reference[len("fb_"):]
else:
if not self.hasPassword():
# no login is required, but possibly another Login type object is required if implemented
return
if len(self.objectValues(portal_type=login_portal_type)):
# already migrated # already migrated
return return
login = self.newContent( login = self.newContent(
portal_type='ERP5 Login', portal_type=login_portal_type,
reference=reference, reference=reference,
) )
login._setEncodedPassword(self.getPassword()) if login_portal_type == "ERP5 Login":
login._setEncodedPassword(self.getPassword())
self._setEncodedPassword(None)
login.validate() login.validate()
self._setEncodedPassword(None)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment