Commit 5067df66 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Refactor code run script on web section context and...

erp5_web_renderjs_ui: Refactor code run script on web section context and improve python to analyse password
parent ba4c99db
"""
The method changeUserPassword ignore came_from if you are in the Web Site context.
"""
REQUEST = context.REQUEST
next_url = context.portal_password.changeUserPassword(password=REQUEST['password'],
password_confirmation=REQUEST['password_confirm'],
password_key=REQUEST['password_key'],
user_login=REQUEST.get('user_login', None),
REQUEST=REQUEST)
root_url = "%s/" % context.getWebSiteValue().absolute_url()
return REQUEST.RESPONSE.redirect("%s&came_from=%s" % (next_url, root_url))
"""
The method changeUserPassword ignore came_from if you are in the Web Site context.
"""
REQUEST = context.REQUEST
response = REQUEST.RESPONSE
portal = context.getPortalObject()
password_confirm, password = REQUEST['password_confirm'], REQUEST['password']
new_url = "".join([x for x in REQUEST["HTTP_REFERER"].split("&")
if "portal_status_message" not in x])
if password_confirm != password:
return response.redirect(
"%s&portal_status_message=%s" % (
new_url,
"New password does not match confirmation")
)
password_key = REQUEST['password_key']
assert password_key
validation_message_list = portal.portal_password.analyzePassword(password, password_key)
if validation_message_list:
message = u' '.join([str(x) for x in validation_message_list])
return response.redirect(
"%s&portal_status_message=%s" % (
new_url,
message)
)
next_url = portal.portal_password.changeUserPassword(password=password,
password_confirmation=password_confirm,
password_key=password_key,
user_login=REQUEST.get('user_login', None),
REQUEST=REQUEST)
root_url = "%s/" % context.getWebSiteValue().absolute_url()
return response.redirect("%s&came_from=%s" % (next_url, root_url))
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PasswordTool_changeUserPassword</string> </value>
<value> <string>WebSection_changeUserPassword</string> </value>
</item>
</dictionary>
</pickle>
......
<html>
<html tal:define="portal here/getPortalObject">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title tal:content="python: here.getPortalObject().getTitle()"></title>
<title tal:content="portal/getTitle"></title>
<link rel="stylesheet" href="gadget_erp5_nojqm.css">
</head>
<body tal:define="form_action string:portal_password/PasswordTool_changeUserPassword;">
<body tal:define="form_action string:WebSection_changeUserPassword;">
<div data-gadget-scope='header'>
<div class="ui-header">
<h1><span i18n:domain="ui" i18n:translate="">Reset Password</span></h1>
......@@ -31,7 +30,8 @@
</section>
<section>
<tal:block tal:condition="python: context.getPortalObject().portal_preferences.isAuthenticationPolicyEnabled()">
<tal:block tal:define="preference_tool python: portal.portal_preferences"
tal:condition="python: preference_tool.isAuthenticationPolicyEnabled() and preference_tool.getPreferredPasswordPolicyReference()">
<label i18n:domain="ui" i18n:translate="">Password Policy</label>
<tal:block tal:replace="structure python: context.Preference_getPasswordPolicy()"></tal:block>
</tal:block>
......
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