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

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

change_password disabled

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