Add test when create credential recovery

We should test the response before send submit the credential recovery.
Fix typo by using named parameters
parent edcd5b37
...@@ -68,7 +68,7 @@ if password:\n ...@@ -68,7 +68,7 @@ if password:\n
\n \n
#Get message from catalog\n #Get message from catalog\n
notification_reference = \'crendential_request-confirmation-%s\' % notification_type\n notification_reference = \'crendential_request-confirmation-%s\' % notification_type\n
notification_message = context.NotificationTool_getDocumentValue(notification_reference, recipient.getLanguage())\n notification_message = context.NotificationTool_getDocumentValue(reference=notification_reference, language=recipient.getLanguage())\n
if notification_message is None:\n if notification_message is None:\n
raise ValueError, \'Unable to found Notification Message with reference "%s".\' % notification_reference\n raise ValueError, \'Unable to found Notification Message with reference "%s".\' % notification_reference\n
\n \n
......
...@@ -55,31 +55,47 @@ ...@@ -55,31 +55,47 @@
Proxy : Manager proxy role is required to make possible for \n Proxy : Manager proxy role is required to make possible for \n
anonymous to create a new Credential Recovery\n anonymous to create a new Credential Recovery\n
\'\'\'\n \'\'\'\n
\n portal = context.getPortalObject()\n
person_module = context.getDefaultModule(\'Person\')\n person_module = portal.getDefaultModule(\'Person\')\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 = context.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
return context.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n return context.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n \n
person = result[0].getObject()\n person = result[0].getObject()\n
# create the credential recovery\n \n
module = context.getDefaultModule(portal_type=\'Credential Recovery\')\n # Check the response\n
credential_recovery = module.newContent(\n question_free_text = person.getDefaultCredentialQuestionQuestionFreeText()\n
question_title = person.getDefaultCredentialQuestionQuestionTitle()\n
question_answer = person.getDefaultCredentialQuestionAnswer().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 \t\tportal_type="Credential Recovery",\n
reference=reference,\n reference=reference,\n
default_credential_question_answer=default_credential_question_answer,\n default_credential_question_answer=default_credential_question_answer,\n
destination_decision=person.getRelativeUrl(),\n destination_decision=person.getRelativeUrl(),\n
language=portal.Localizer.get_selected_language())\n language=portal.Localizer.get_selected_language())\n
credential_recovery.submit()\n credential_recovery.submit()\n
message = "Credential Recovery Created."\n
keep_items = {}\n
dialog_id = \'login_form\'\n
else:\n
message = "You didn\'t enter the correct answer."\n
keep_items = {\'default_credential_question_question_free_text\': question_free_text,\n
\'default_credential_question_question_title\': question_title,\n
\'reference\': reference}\n
\n \n
portal_status_message = context.Base_translateString("Credential Recovery Created.")\n keep_items[\'portal_status_message\'] = portal.Base_translateString(message)\n
return context.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n return context.Base_redirect(dialog_id, keep_items = keep_items)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>reference=None, default_credential_question_answer=None, **kw</string> </value> <value> <string>reference=None, default_credential_question_answer=None, dialog_id=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
332 333
\ 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