Back to index

plone3  3.1.7
change_password.py
Go to the documentation of this file.
00001 ##parameters=password, confirm, domains=None, **kw
00002 ##title=Action to change password
00003 ##
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.utils import Message as _
00006 
00007 mtool = getToolByName(script, 'portal_membership')
00008 rtool = getToolByName(script, 'portal_registration')
00009 
00010 result = rtool.testPasswordValidity(password, confirm)
00011 if result:
00012     return context.setStatus(False, result)
00013 
00014 member = mtool.getAuthenticatedMember()
00015 mtool.setPassword(password, domains, REQUEST=context.REQUEST)
00016 if member.getProperty('last_login_time') == DateTime('1999/01/01'):
00017     member.setProperties(last_login_time='2000/01/01')
00018 
00019 mtool.credentialsChanged(password, context.REQUEST)
00020 
00021 return context.setStatus(True, _(u'Password changed.'))