Commit e1915cb8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Fixup when restart from a website

  The suffixes present on the come_from are incompatible with the addition done by portal_password
parent 7bbea43e
"""
File a password expire event.
"""
from DateTime import DateTime
from Products.ZSQLCatalog.SQLCatalog import Query
from erp5.component.module.DateUtils import addToDate
portal = context.getPortalObject()
portal_preferences = portal.portal_preferences
if not portal_preferences.isAuthenticationPolicyEnabled() or \
not portal_preferences.isPreferredSystemRecoverExpiredPassword():
# no policy, no sense to file expire at all or symply system do not configured to
return
user = context.getParentValue()
username = context.getReference()
# Prevent creating new recovery if one was recently created
recovery_list = portal.portal_catalog(
portal_type="Credential Recovery",
reference=username,
default_destination_decision_uid=user.getUid(),
creation_date=Query(range="min", creation_date=addToDate(DateTime(), {'day': -1})),
limit=1)
if recovery_list:
return
tag = 'credential_recovery_%s' %context.getReference()
if portal.portal_activities.countMessageWithTag(tag):
return
if context.getWebSectionValue() is not None:
context.REQUEST.set('came_from', context.getWebSectionValue().absolute_url())
module = portal.getDefaultModule(portal_type='Credential Recovery')
credential_recovery = module.newContent(
portal_type="Credential Recovery",
reference=username,
destination_decision_value=user,
language=portal.Localizer.get_selected_language(),
activate_kw={'tag': tag})
context.serialize()
credential_recovery.submit()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Login_notifyPasswordExpire</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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