[1461] | 1 | ##parameters= |
---|
| 2 | # $Id: change_password.py 1467 2007-02-22 10:48:52Z joachim $ |
---|
| 3 | """ |
---|
| 4 | process the Application Form |
---|
| 5 | return html renderer + psm |
---|
| 6 | """ |
---|
| 7 | request = context.REQUEST |
---|
| 8 | import DateTime,logging |
---|
[1467] | 9 | try: |
---|
| 10 | from Products.zdb import set_trace |
---|
| 11 | except: |
---|
| 12 | def set_trace(): |
---|
| 13 | pass |
---|
| 14 | |
---|
[1461] | 15 | current = DateTime.DateTime() |
---|
| 16 | #pr = context.portal_registration |
---|
| 17 | logger = logging.getLogger('Student.change_password') |
---|
| 18 | validate = request.has_key("change_password") |
---|
| 19 | students_dir = context.portal_directories.students |
---|
| 20 | lt = context.portal_layouts |
---|
[1467] | 21 | wt = context.waeup_tool |
---|
| 22 | student_id = context.getStudentId() |
---|
[1461] | 23 | res,psm,ds = lt.renderLayout(layout_id= 'student_change_password', |
---|
| 24 | schema_id= 'student_change_password', |
---|
| 25 | context=context, |
---|
| 26 | mapping=validate and request, |
---|
| 27 | ob = {}, |
---|
| 28 | layout_mode='edit', |
---|
| 29 | button = "Change Password", |
---|
| 30 | commit = False, |
---|
| 31 | ) |
---|
| 32 | if psm == '': |
---|
| 33 | return context.change_password_form(rendered = res, |
---|
| 34 | psm = None, |
---|
| 35 | ds = ds, |
---|
| 36 | mode = "edit", |
---|
| 37 | formaction = "change_password", |
---|
| 38 | button = "Change Password", |
---|
| 39 | ) |
---|
| 40 | elif psm == 'invalid': |
---|
| 41 | psm = "Please correct your input!" |
---|
| 42 | return context.change_password_form(rendered = res, |
---|
[1467] | 43 | psm = psm, |
---|
[1461] | 44 | ds = ds, |
---|
| 45 | mode = "edit", |
---|
| 46 | formaction = "change_password", |
---|
| 47 | button = "Change Password", |
---|
| 48 | ) |
---|
| 49 | else: |
---|
[1467] | 50 | pass |
---|
| 51 | old_password = request.get('widget__old_password') |
---|
| 52 | if not wt.checkPassword(student_id,old_password): |
---|
| 53 | psm = "Old Password is not correct" |
---|
[1461] | 54 | return context.change_password_form(rendered = res, |
---|
[1467] | 55 | psm = psm, |
---|
| 56 | ds = ds, |
---|
| 57 | mode = "edit", |
---|
| 58 | formaction = "change_password", |
---|
| 59 | button = "Change Password", |
---|
| 60 | ) |
---|
| 61 | #set_trace() |
---|
| 62 | password = request.get('widget__password') |
---|
| 63 | wt.editPassword(student_id,password) |
---|
| 64 | args = {} |
---|
| 65 | args['__ac_name'] = student_id |
---|
| 66 | args['__ac_password'] = password |
---|
| 67 | from urllib import urlencode |
---|
| 68 | url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) |
---|
| 69 | return request.RESPONSE.redirect(url) |
---|