source: WAeUP_SRP/base/skins/waeup_student/change_password.py @ 2828

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

change_password disabled

  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1##parameters=
2# $Id: change_password.py 1628 2007-03-23 11:00:24Z henrik $
3"""
4
5"""
6
7return
8
9
10
11
12
13
14
15
16request = context.REQUEST
17import DateTime,logging
18try:
19    from Products.zdb import set_trace
20except:
21    def set_trace():
22        pass
23
24current = DateTime.DateTime()
25#pr = context.portal_registration
26logger = logging.getLogger('Skins.change_password')
27validate = request.has_key("change_password")
28students_dir = context.portal_directories.students
29mtool = context.portal_membership
30member = mtool.getAuthenticatedMember()
31member_id = str(member)
32lt = context.portal_layouts
33wt = context.waeup_tool
34requested_id = context.getStudentId()
35if requested_id and not context.isStaff() and member_id != requested_id:
36    logger.info('%s tried to access %s' % (member_id,requested_id))
37    return None
38elif context.isStaff():
39    student_id = requested_id
40else:
41    student_id = member_id
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,
62                                 psm = psm,
63                                 ds = ds,
64                                 mode = "edit",
65                                 formaction = "change_password",
66                                 button = "Change Password",
67                                 )
68else:
69    pass
70old_password = request.get('widget__old_password')
71if not wt.checkPassword(student_id,old_password):
72    psm = "Old Password is not correct"
73    return context.change_password_form(rendered = res,
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
86logger.info('%s changed password from %s to %s' % (member_id,old_password,password))
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.