Changeset 2710 for WAeUP_SRP/base


Ignore:
Timestamp:
19 Nov 2007, 20:29:10 (17 years ago)
Author:
Henrik Bettermann
Message:

see ticket #398

Joachim, please check!

Location:
WAeUP_SRP/base
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2704 r2710  
    445445    security.declareProtected(View,'getCredential') ###(
    446446    def getCredential(self,student_id):
    447         "return a student password"
    448447        student_entry = getattr(self.portal_directories.students,student_id,None)
    449448        if not self.isStaff():
     
    458457    ###)
    459458
    460     security.declarePublic('checkPassword') ###(
     459    security.declarePublic('checkPassword')
    461460    def checkPassword(self,student_id,password):
    462         "return a student password"
    463461        student_entry = getattr(self.portal_directories.students,student_id,None)
    464462        if student_entry is None:
    465463            return False
    466464        return getattr(student_entry,"password","not set") == password
    467     ###)
     465       
     466    security.declarePublic('checkGenericPassword')
     467    def checkGenericPassword(self,member_id):
     468        member_entry = getattr(self.portal_directories.members,member_id,None)
     469        if member_entry is None:
     470            return False
     471        ltool = getToolByName(self, 'portal_layouts')   
     472        unsecure_words = ltool._getOb('members')['w__password'].check_words
     473        return getattr(member_entry,"password","not set") in unsecure_words
    468474
    469475    security.declareProtected(ModifyPortalContent,'editPassword') ###(
     
    18291835                if not validators[k](ds,mode=mode):
    18301836                    if error_count:
    1831                         error_string += ' ++ ' 
     1837                        error_string += ' ++ '
    18321838                    error_string += "%s: %s" % (k,
    18331839                                                  self.translation_service(ds.getError(k),
  • WAeUP_SRP/base/Widgets.py

    r2709 r2710  
    1010from Products.CMFCore.utils import getToolByName
    1111from Products.CPSSchemas.BasicWidgets import CPSBooleanWidget, CPSWidget, CPSStringWidget, CPSEmailWidget,CPSImageWidget
    12 from Products.CPSSchemas.BasicWidgets import CPSFileWidget
     12from Products.CPSSchemas.BasicWidgets import CPSFileWidget, CPSPasswordWidget
    1313from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget
    1414from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget
     
    2929
    3030#from zLOG import LOG, DEBUG
     31
     32
     33class WAeUPPasswordWidget(CPSPasswordWidget):
     34    """WAeUP Password Widget"""
     35    meta_type = 'WAeUP Password Widget'
     36
     37    _properties = CPSStringWidget._properties + (
     38        {'id': 'password_widget', 'type': 'string', 'mode': 'w',
     39         'label': 'Password widget to compare with'},
     40        {'id': 'check_lower', 'type': 'boolean', 'mode': 'w',
     41         'label': 'Checking at least one lower case [a-z]'},
     42        {'id': 'check_upper', 'type': 'boolean', 'mode': 'w',
     43         'label': 'Checking at least one upper case [A-Z]'},
     44        {'id': 'check_digit', 'type': 'boolean', 'mode': 'w',
     45         'label': 'Checking at least one digit [0-9]'},
     46        {'id': 'check_extra', 'type': 'boolean', 'mode': 'w',
     47         'label': 'Checking at least one extra char other than [a-zA-Z0-9]'},
     48        {'id': 'check_words', 'type': 'string', 'mode': 'w',
     49         'label': 'Checking for words'},
     50        )       
     51
     52    field_types = ('CPS Password Field',)
     53    password_widget = ''
     54    check_lower = 0
     55    check_upper = 0
     56    check_digit = 0
     57    check_extra = 0
     58    check_words = ''
     59    display_width = 8
     60    size_min = 5
     61    size_max = 8
     62
     63    def validate(self, datastructure, **kw):
     64        """Validate datastructure and update datamodel."""
     65        widget_id = self.getWidgetId()
     66        value = datastructure[widget_id]
     67        err = 0
     68        try:
     69            v = str(value).strip()
     70        except ValueError:
     71            err = 'cpsschemas_err_string'
     72        else:
     73            if self.password_widget:
     74                # here we only check that that our confirm match the pwd
     75                pwidget_id = self.password_widget
     76                pvalue = datastructure[pwidget_id]
     77                datastructure[widget_id] = ''
     78                datastructure[pwidget_id] = ''
     79                pv = str(pvalue).strip()
     80                if pv and v != pv:
     81                    err = 'cpsschemas_err_password_mismatch'
     82            else:
     83                if not v:
     84                    if self.is_required:
     85                        datamodel = datastructure.getDataModel()
     86                        if not datamodel[self.fields[0]]:
     87                            err = 'cpsschemas_err_required'
     88                else:
     89                    # checking pw consistancy
     90                    len_v = len(v)
     91                    if not err and self.size_max and len_v > self.size_max:
     92                        err = 'cpsschemas_err_string_too_long'
     93                    if not err and self.size_min and len_v < self.size_min:
     94                        err = 'cpsschemas_err_password_size_min'
     95                    if not err and self.check_lower and not search(r'[a-z]', v):
     96                        err = 'cpsschemas_err_password_lower'
     97                    if not err and self.check_upper and not search(r'[A-Z]', v):
     98                        err = 'cpsschemas_err_password_upper'
     99                    if not err and self.check_digit and not search(r'[0-9]', v):
     100                        err = 'cpsschemas_err_password_digit'
     101                    if not err and self.check_extra and not search(r'[^a-zA-Z0-9]',
     102                                                                   v):
     103                        err = 'cpsschemas_err_password_extra'
     104                    if not err and v in self.check_words:
     105                        err = 'Your password is unsecure, please choose another password!'
     106
     107        if err:
     108            datastructure[widget_id] = ''
     109            datastructure.setError(widget_id, err)
     110        elif v:
     111            datamodel = datastructure.getDataModel()
     112            datamodel[self.fields[0]] = v
     113
     114        return not err
     115
     116InitializeClass(WAeUPPasswordWidget)
     117
     118widgetRegistry.register(WAeUPPasswordWidget)
     119
    31120
    32121class CPSSelectWidgetForRecord(CPSSelectWidget): ###(
  • WAeUP_SRP/base/skins/cps_custom/logged_in.py

    r2579 r2710  
    3636is_anon = mtool.isAnonymousUser()
    3737member = mtool.getAuthenticatedMember()
     38
     39if context.isStaff():
     40    is_unsecure = context.waeup_tool.checkGenericPassword(str(member))
     41    if is_unsecure:
     42        response.expireCookie('__ac', path='/')
     43        return response.redirect("%s/user_logged_in_disabled" % context.portal_url())
     44
    3845#load_passport = hasattr(context.waeup_tool,'loadStudentFoto')
    3946
     
    151158        if s_review_state == "student_created":
    152159            wftool.doActionFor(student,'admit')
    153             s_review_state = 'admitted'       
     160            s_review_state = 'admitted'
    154161
    155162        if s_review_state == "admitted" and a_review_state == 'created':
Note: See TracChangeset for help on using the changeset viewer.