Commit 2d38317b authored by Rafael Monnerat's avatar Rafael Monnerat

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

parent 02dded63
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 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=self.getPortalObject().getPortalLoginTypeList())):
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,
)
if login_portal_type == "ERP5 Login":
login._setEncodedPassword(self.getPassword())
login.validate()
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