Commit d586d541 authored by Rafael Monnerat's avatar Rafael Monnerat

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

parent 0c45ae38
def migrateToERP5Login(self):
assert self.getPortalType() == 'Person'
login_portal_type = 'ERP5 Login'
reference = self.getReference()
if not reference:
# no user id and no login is required
return
if not self.hasUserId() or self.getUserId() == reference:
if not (self.hasUserId() or self.getUserId() == reference):
self._baseSetUserId(reference)
self.reindexObject()
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=self.getPortalObject().getPortalLoginTypeList())):
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():
# 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
return
login = self.newContent(
portal_type='ERP5 Login',
portal_type=login_portal_type,
reference=reference,
)
login._setEncodedPassword(self.getPassword())
if login_portal_type == "ERP5 Login":
login._setEncodedPassword(self.getPassword())
self._setEncodedPassword(None)
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