9cb4b1deccde9d3213bbe4fb562a51d74f67511f
[Plinn.git] / Products / Plinn / skins / generic / password_reset_form.py
1 ##parameters=validate=''
2 from Products.CMFCore.utils import getUtilityByInterfaceName
3 from Products.Plinn.utils import Message as _
4 utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool')
5 atool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
6
7 form = context.REQUEST.form
8 uuid = traverse_subpath[0]
9
10 passwordChanged = False
11
12 if validate :
13 userid = context.reset_password_control(uuid=uuid, **form)
14 if userid :
15 passwordChanged = True
16
17 options = {}
18 options['uuid'] = uuid
19 options['passwordChanged'] = passwordChanged
20 if passwordChanged :
21 hidden_vars = ({'name' : '__ac_name', 'value' : userid},
22 {'name' : '__ac_password', 'value' : form['password']},
23 {'name' : 'noAjax', 'value' : '1'})
24 target = utool()
25 buttons = ({'name': 'login', 'value': _(' Login ')},)
26 else :
27 hidden_vars = []
28 target = '%s/password_reset_form/%s' % (utool(), uuid)
29 buttons = ({'name': 'validate', 'value': _('Update Password')},)
30
31 options['form'] = { 'action': target,
32 'listButtonInfos': tuple(buttons),
33 'listHiddenVarInfos': hidden_vars }
34
35
36 return context.password_reset_template(**options)