Commit 85c42b3c authored by Aurel's avatar Aurel Committed by Jérome Perrin

when on web-site, use the notification message reference defined

also make redirection stay on website
parent 5df483be
...@@ -61,8 +61,8 @@ if context.hasDocumentReference():\n ...@@ -61,8 +61,8 @@ if context.hasDocumentReference():\n
message_reference = context.getDocumentReference()\n message_reference = context.getDocumentReference()\n
else:\n else:\n
message_reference = portal.portal_preferences.getPreferredCredentialPasswordRecoveryMessageReference()\n message_reference = portal.portal_preferences.getPreferredCredentialPasswordRecoveryMessageReference()\n
if message_reference is None:\n if message_reference is None:\n
raise ValueError, "Preference not configured"\n raise ValueError, "Preference not configured"\n
notification_message = portal.NotificationTool_getDocumentValue(message_reference,\n notification_message = portal.NotificationTool_getDocumentValue(message_reference,\n
context.getLanguage())\n context.getLanguage())\n
\n \n
......
...@@ -63,7 +63,10 @@ for person in person_list:\n ...@@ -63,7 +63,10 @@ for person in person_list:\n
usernames = " ".join(usernames)\n usernames = " ".join(usernames)\n
\n \n
reference_list = [x.getReference() for x in person_list]\n reference_list = [x.getReference() for x in person_list]\n
message_reference = portal.portal_preferences.getPreferredCredentialUsernameRecoveryMessageReference()\n if context.hasDocumentReference():\n
message_reference = context.getDocumentReference()\n
else:\n
message_reference = portal.portal_preferences.getPreferredCredentialUsernameRecoveryMessageReference()\n
if message_reference is None:\n if message_reference is None:\n
raise ValueError, "Preference not configured"\n raise ValueError, "Preference not configured"\n
\n \n
......
...@@ -56,14 +56,19 @@ ...@@ -56,14 +56,19 @@
\'\'\'\n \'\'\'\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
person_module = portal.getDefaultModule(\'Person\')\n person_module = portal.getDefaultModule(\'Person\')\n
request = context.REQUEST\n
web_site = context.getWebSiteValue()\n
if web_site:\n
request.set("came_from", web_site.absolute_url())\n
if choice == "password":\n if choice == "password":\n
request = context.REQUEST\n
request.set(\'reference\', reference)\n request.set(\'reference\', reference)\n
portal_preferences = context.portal_preferences\n portal_preferences = context.portal_preferences\n
result = person_module.searchFolder(reference={\'query\': reference, \'key\': \'ExactMatch\'})\n result = person_module.searchFolder(reference={\'query\': reference, \'key\': \'ExactMatch\'})\n
if len(result) != 1:\n if len(result) != 1:\n
portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
return context.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n if web_site:\n
return web_site.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n \n
person = result[0]\n person = result[0]\n
\n \n
...@@ -93,7 +98,9 @@ elif choice == "username":\n ...@@ -93,7 +98,9 @@ elif choice == "username":\n
result = portal.portal_catalog(portal_type="Email", parent_portal_type="Person", **query_kw)\n result = portal.portal_catalog(portal_type="Email", parent_portal_type="Person", **query_kw)\n
if len(result) == 0:\n if len(result) == 0:\n
portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
return context.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n if web_site:\n
return web_site.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
person_list = [x.getParentValue() for x in result]\n person_list = [x.getParentValue() for x in result]\n
return context.ERP5Site_newCredentialRecovery(default_email_text=default_email_text, person_list=person_list)\n return context.ERP5Site_newCredentialRecovery(default_email_text=default_email_text, person_list=person_list)\n
</string> </value> </string> </value>
......
...@@ -66,7 +66,8 @@ def createCredentialRecovery(**kw):\n ...@@ -66,7 +66,8 @@ def createCredentialRecovery(**kw):\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n portal_preferences = portal.portal_preferences\n
keep_items = {}\n keep_items = {}\n
\n web_site = context.getWebSiteValue()\n
document_reference = None\n
if default_email_text is not None:\n if default_email_text is not None:\n
# Case for recovery of username\n # Case for recovery of username\n
if person_list is None:\n if person_list is None:\n
...@@ -74,14 +75,19 @@ if default_email_text is not None:\n ...@@ -74,14 +75,19 @@ if default_email_text is not None:\n
result = portal.portal_catalog(portal_type="Email", parent_portal_type="Person", **query_kw)\n result = portal.portal_catalog(portal_type="Email", parent_portal_type="Person", **query_kw)\n
if len(result) == 0:\n if len(result) == 0:\n
portal_status_message = portal.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n portal_status_message = portal.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
if web_site:\n
return web_site.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n return portal.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n \n
person_list = [x.getObject().getParentValue() for x in result]\n person_list = [x.getObject().getParentValue() for x in result]\n
\n \n
# Create recovery\n # Create recovery\n
message = "We have sent you an email containing your username(s). Please check your inbox and your junk/spam mail for this email."\n message = "We have sent you an email containing your username(s). Please check your inbox and your junk/spam mail for this email."\n
if web_site:\n
document_reference = web_site.getCredentialUsernameRecoveryMessageReference() \n
createCredentialRecovery(default_email_text=default_email_text,\n createCredentialRecovery(default_email_text=default_email_text,\n
destination_decision_value_list=person_list,\n destination_decision_value_list=person_list,\n
document_reference=document_reference,\n
language=portal.Localizer.get_selected_language())\n language=portal.Localizer.get_selected_language())\n
else:\n else:\n
# Case for recovery of password\n # Case for recovery of password\n
...@@ -90,10 +96,11 @@ else:\n ...@@ -90,10 +96,11 @@ else:\n
result = person_module.searchFolder(reference=reference)\n result = person_module.searchFolder(reference=reference)\n
if len(result) != 1:\n if len(result) != 1:\n
portal_status_message = portal.Base_translateString("Can\'t find corresponding person, it\'s not possible to recover your credentials.")\n portal_status_message = portal.Base_translateString("Can\'t find corresponding person, it\'s not possible to recover your credentials.")\n
return context.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n if web_site:\n
web_site.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n
return portal.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n \n
person_list = [result[0].getObject(),]\n person_list = [result[0].getObject(),]\n
\n
\n \n
# Check the response\n # Check the response\n
person = person_list[0]\n person = person_list[0]\n
...@@ -103,15 +110,20 @@ else:\n ...@@ -103,15 +110,20 @@ else:\n
question_answer = question_answer and question_answer.lower()\n question_answer = question_answer and question_answer.lower()\n
answer = default_credential_question_answer and default_credential_question_answer.lower() or \'\'\n answer = default_credential_question_answer and default_credential_question_answer.lower() or \'\'\n
message = "We have sent you an email to enable you to reset your password. Please check your inbox and your junk/spam mail for this email and follow the link to reset your password."\n message = "We have sent you an email to enable you to reset your password. Please check your inbox and your junk/spam mail for this email and follow the link to reset your password."\n
if web_site:\n
document_reference = web_site.getCredentialPasswordRecoveryMessageReference()\n
\n
if (question_title or question_free_text) and (answer == question_answer):\n if (question_title or question_free_text) and (answer == question_answer):\n
createCredentialRecovery(reference=reference,\n createCredentialRecovery(reference=reference,\n
default_credential_question_answer=default_credential_question_answer,\n default_credential_question_answer=default_credential_question_answer,\n
destination_decision_value_list=person_list,\n destination_decision_value_list=person_list,\n
document_reference=document_reference,\n
language=portal.Localizer.get_selected_language())\n language=portal.Localizer.get_selected_language())\n
elif (question_free_text is None and question_answer is None) or \\\n elif (question_free_text is None and question_answer is None) or \\\n
not portal_preferences.isPreferredAskCredentialQuestion():\n not portal_preferences.isPreferredAskCredentialQuestion():\n
createCredentialRecovery(reference=reference,\n createCredentialRecovery(reference=reference,\n
destination_decision_value_list=person_list,\n destination_decision_value_list=person_list,\n
document_reference=document_reference,\n
language=portal.Localizer.get_selected_language())\n language=portal.Localizer.get_selected_language())\n
else:\n else:\n
message = "You didn\'t enter the correct answer."\n message = "You didn\'t enter the correct answer."\n
...@@ -120,6 +132,8 @@ else:\n ...@@ -120,6 +132,8 @@ else:\n
\'reference\': reference}\n \'reference\': reference}\n
\n \n
keep_items[\'portal_status_message\'] = portal.Base_translateString(message)\n keep_items[\'portal_status_message\'] = portal.Base_translateString(message)\n
if web_site:\n
return web_site.Base_redirect(form_id=\'login_form\', keep_items=keep_items)\n
return portal.Base_redirect(form_id=\'login_form\', keep_items=keep_items)\n return portal.Base_redirect(form_id=\'login_form\', keep_items=keep_items)\n
</string> </value> </string> </value>
</item> </item>
......
431 432
\ No newline at end of file \ No newline at end of file
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