Commit 1ece5b26 authored by Rafael Monnerat's avatar Rafael Monnerat

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

parent 3d929b7d
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 reference.startswith("go_"):
login_portal_type = "Google Login"
reference = self.getDefaultEmailText()
elif reference.startswith("fb_"):
login_portal_type = "Facebook Login"
reference = reference[len("fb_"):]
else:
if not self.hasPassword(): if not self.hasPassword():
# no login is required, but possibly another Login type object is required if implemented # no login is required, but possibly another Login type object is required if implemented
return return
if len(self.objectValues(portal_type=self.getPortalObject().getPortalLoginTypeList())): 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,
) )
if login_portal_type == "ERP5 Login":
login._setEncodedPassword(self.getPassword()) login._setEncodedPassword(self.getPassword())
login.validate()
self._setEncodedPassword(None) self._setEncodedPassword(None)
login.validate()
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