Commit 0a394578 authored by Aurel's avatar Aurel Committed by Kazuhiko Shiozaki

make generation of reset url configurable through a type base script

parent 84e59af2
...@@ -39,7 +39,6 @@ import time, random ...@@ -39,7 +39,6 @@ import time, random
from hashlib import md5 as md5_new from hashlib import md5 as md5_new
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Acquisition import aq_base
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
from urllib import urlencode from urllib import urlencode
...@@ -90,19 +89,26 @@ class PasswordTool(BaseTool): ...@@ -90,19 +89,26 @@ class PasswordTool(BaseTool):
return key return key
security.declareProtected('Manage users', 'getResetPasswordUrl') security.declareProtected('Manage users', 'getResetPasswordUrl')
def getResetPasswordUrl(self, user_login=None, key=None, site_url): def getResetPasswordUrl(self, user_login=None, key=None, site_url=None):
if user_login is not None: if user_login is not None:
# XXX Backward compatibility # XXX Backward compatibility
key = self.getResetPasswordKey(user_login) key = self.getResetPasswordKey(user_login)
parameter = urlencode(dict(reset_key=reset_key, parameter = urlencode(dict(reset_key=key))
user_login=user_login)) method = self._getTypeBasedMethod("getSiteUrl")
url = "%s/portal_password/%s?%s" % ( if method is not None:
site_url, base_url = method()
'PasswordTool_viewResetPassword', else:
parameter) base_url = "%s/portal_password/PasswordTool_viewResetPassword" % (
site_url,)
url = "%s?%s" %(base_url, parameter)
return url return url
security.declareProtected('Manage users', 'getResetPasswordUrl')
def getExpirationDateForKey(self, key=None):
return self._password_request_dict[key][1]
def mailPasswordResetRequest(self, user_login=None, REQUEST=None, def mailPasswordResetRequest(self, user_login=None, REQUEST=None,
notification_message=None, sender=None, notification_message=None, sender=None,
store_as_event=False): store_as_event=False):
...@@ -160,7 +166,7 @@ class PasswordTool(BaseTool): ...@@ -160,7 +166,7 @@ class PasswordTool(BaseTool):
# send mail # send mail
message_dict = {'instance_name':self.getPortalObject().getTitle(), message_dict = {'instance_name':self.getPortalObject().getTitle(),
'reset_password_link':url, 'reset_password_link':url,
'expiration_date':self._password_request_dict[key][1]} 'expiration_date':self.getExpirationDateForKey(key).strftime('%Y/%m/%d %H:%M')}
if notification_message is None: if notification_message is None:
subject = translateString("[${instance_name}] Reset of your password", subject = translateString("[${instance_name}] Reset of your password",
......
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