source: WAeUP_SRP/trunk/skins/waeup_student/change_password.py @ 1536

Last change on this file since 1536 was 1527, checked in by Henrik Bettermann, 18 years ago

new members allowed to send authentication data

  • Property svn:keywords set to Id
File size: 2.7 KB
RevLine 
[1461]1##parameters=
2# $Id: change_password.py 1527 2007-03-07 18:29:40Z henrik $
3"""
[1527]4
[1461]5"""
6request = context.REQUEST
7import DateTime,logging
[1467]8try:
9    from Products.zdb import set_trace
10except:
11    def set_trace():
12        pass
[1474]13
[1461]14current = DateTime.DateTime()
15#pr = context.portal_registration
16logger = logging.getLogger('Student.change_password')
17validate = request.has_key("change_password")
18students_dir = context.portal_directories.students
[1476]19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21member_id = str(member)
[1461]22lt = context.portal_layouts
[1467]23wt = context.waeup_tool
[1476]24requested_id = context.getStudentId()
25if requested_id and not context.isStaff() and member_id != requested_id:
26    logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id))
27    return None
28elif context.isStaff():
29    student_id = requested_id
30else:
31    student_id = member_id
[1461]32res,psm,ds = lt.renderLayout(layout_id= 'student_change_password',
33                      schema_id= 'student_change_password',
34                      context=context,
35                      mapping=validate and request,
36                      ob = {},
37                      layout_mode='edit',
38                      button = "Change Password",
39                      commit = False,
40                      )
41if psm == '':
42    return context.change_password_form(rendered = res,
43                                 psm = None,
44                                 ds = ds,
45                                 mode = "edit",
46                                 formaction = "change_password",
47                                 button = "Change Password",
48                                 )
49elif psm == 'invalid':
50    psm = "Please correct your input!"
51    return context.change_password_form(rendered = res,
[1467]52                                 psm = psm,
[1461]53                                 ds = ds,
54                                 mode = "edit",
55                                 formaction = "change_password",
56                                 button = "Change Password",
57                                 )
58else:
[1467]59    pass
60old_password = request.get('widget__old_password')
61if not wt.checkPassword(student_id,old_password):
62    psm = "Old Password is not correct"
[1461]63    return context.change_password_form(rendered = res,
[1467]64                             psm = psm,
65                             ds = ds,
66                             mode = "edit",
67                             formaction = "change_password",
68                             button = "Change Password",
69                             )
70#set_trace()
71password = request.get('widget__password')
72wt.editPassword(student_id,password)
73args = {}
74args['__ac_name'] = student_id
75args['__ac_password'] = password
76from urllib import urlencode
77url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
78return request.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.