Changeset 1467 for WAeUP_SRP


Ignore:
Timestamp:
22 Feb 2007, 10:48:52 (18 years ago)
Author:
joachim
Message:

add change password functionality

Location:
WAeUP_SRP/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTool.py

    r1462 r1467  
    9696
    9797    security.declarePublic('checkPassword') ###(
    98     def checkPassword(self,password):
     98    def checkPassword(self,student_id,password):
    9999        "return a student password"
    100100        student_entry = getattr(self.portal_directories.students,student_id,None)
     
    102102            return False
    103103        return getattr(student_entry,"password","not set") == password
     104    ###)
     105
     106    security.declarePublic('editPassword') ###(
     107    def editPassword(self,student_id,password):
     108        "edit a student password"
     109        student_entry = getattr(self.portal_directories.students,student_id,None)
     110        if student_entry is None:
     111            return
     112        setattr(student_entry,'password',password)
    104113    ###)
    105114
  • WAeUP_SRP/trunk/profiles/default/layouts/student_change_password.xml

    r1461 r1467  
    1313      <element value="old_password"/>
    1414    </property>
     15    <property name="is_required">True</property>
    1516    <property name="label">Old Password</property>
    1617    <property name="label_edit">Old Password</property>
     
    1819    <property name="hidden_layout_modes"/>
    1920    <property name="hidden_readonly_layout_modes"/>
    20     <property name="password_widget">password</property>
    21     <property name="check_digit">True</property>
     21    <property name="password_widget"></property>
     22    <property name="check_digit">False</property>
    2223    <property name="size_min">6</property>
    2324  </widget>
     
    4142      <element value="repeat_password"/>
    4243    </property>
     44    <property name="is_required">True</property>
    4345    <property name="label">Repeat Password</property>
    4446    <property name="label_edit">Repeat Password</property>
  • WAeUP_SRP/trunk/skins/waeup_student/change_password.py

    r1461 r1467  
    77request = context.REQUEST
    88import DateTime,logging
    9 
     9try:
     10    from Products.zdb import set_trace
     11except:
     12    def set_trace():
     13        pass
     14   
    1015current = DateTime.DateTime()
    1116#pr = context.portal_registration
     
    1419students_dir = context.portal_directories.students
    1520lt = context.portal_layouts
     21wt = context.waeup_tool
     22student_id = context.getStudentId()
    1623res,psm,ds = lt.renderLayout(layout_id= 'student_change_password',
    1724                      schema_id= 'student_change_password',
     
    3441    psm = "Please correct your input!"
    3542    return context.change_password_form(rendered = res,
    36                                  psm = None,
     43                                 psm = psm,
    3744                                 ds = ds,
    3845                                 mode = "edit",
     
    4148                                 )
    4249else:
    43     student_id = context.getStudentId()
    44     old_password = request.get('widget__old_password')
    45     password = request.get('widget__password')
    46     entry = students_dir.getEntry
    47     context.portal_membership.setPassword(password)
    48     psm = "Your Password has been changed"
     50    pass
     51old_password = request.get('widget__old_password')
     52if not wt.checkPassword(student_id,old_password):
     53    psm = "Old Password is not correct"
    4954    return context.change_password_form(rendered = res,
    50                                  psm = None,
    51                                  ds = ds,
    52                                  mode = "edit",
    53                                  formaction = "change_password",
    54                                  button = "Change Password",
    55                                  )
     55                             psm = psm,
     56                             ds = ds,
     57                             mode = "edit",
     58                             formaction = "change_password",
     59                             button = "Change Password",
     60                             )
     61#set_trace()
     62password = request.get('widget__password')
     63wt.editPassword(student_id,password)
     64args = {}
     65args['__ac_name'] = student_id
     66args['__ac_password'] = password
     67from urllib import urlencode
     68url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
     69return request.RESPONSE.redirect(url)
Note: See TracChangeset for help on using the changeset viewer.