Commit 3b98ce30 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor script to allow create Credential Recoveries when question and answer are None.

parent 6996139b
......@@ -55,11 +55,18 @@
Proxy : Manager proxy role is required to make possible for \n
anonymous to create a new Credential Recovery\n
\'\'\'\n
def createCredentialRecovery(**kw):\n
module = portal.getDefaultModule(portal_type=\'Credential Recovery\')\n
credential_recovery = module.newContent(\n
\t\tportal_type="Credential Recovery",\n
**kw)\n
credential_recovery.submit()\n
\n
portal = context.getPortalObject()\n
person_module = portal.getDefaultModule(\'Person\')\n
result = person_module.searchFolder(reference=reference)\n
if len(result) != 1:\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 recovery your credentials.")\n
return context.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n
person = result[0].getObject()\n
......@@ -67,22 +74,23 @@ person = result[0].getObject()\n
# Check the response\n
question_free_text = person.getDefaultCredentialQuestionQuestionFreeText()\n
question_title = person.getDefaultCredentialQuestionQuestionTitle()\n
question_answer = person.getDefaultCredentialQuestionAnswer().lower()\n
question_answer = person.getDefaultCredentialQuestionAnswer()\n
question_answer = question_answer and question_answer.lower()\n
answer = default_credential_question_answer and default_credential_question_answer.lower() or \'\'\n
\n
if (question_title or question_title) and (answer == question_answer):\n
# create the credential recovery\n
module = portal.getDefaultModule(portal_type=\'Credential Recovery\')\n
credential_recovery = module.newContent(\n
\t\tportal_type="Credential Recovery",\n
reference=reference,\n
keep_items = {}\n
message = "Credential Recovery Created."\n
dialog_id = dialog_id or "login_form"\n
\n
if question_title and (answer == question_answer):\n
createCredentialRecovery(reference=reference,\n
default_credential_question_answer=default_credential_question_answer,\n
destination_decision=person.getRelativeUrl(),\n
language=portal.Localizer.get_selected_language())\n
credential_recovery.submit()\n
message = "Credential Recovery Created."\n
keep_items = {}\n
dialog_id = \'login_form\'\n
elif question_free_text is None and question_answer is None:\n
createCredentialRecovery(reference=reference,\n
destination_decision=person.getRelativeUrl(),\n
language=portal.Localizer.get_selected_language())\n
else:\n
message = "You didn\'t enter the correct answer."\n
keep_items = {\'default_credential_question_question_free_text\': question_free_text,\n
......@@ -90,7 +98,7 @@ else:\n
\'reference\': reference}\n
\n
keep_items[\'portal_status_message\'] = portal.Base_translateString(message)\n
return context.Base_redirect(dialog_id, keep_items = keep_items)\n
return context.Base_redirect(dialog_id, keep_items=keep_items)\n
</string> </value>
</item>
<item>
......
353
\ No newline at end of file
354
\ 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