Changeset 2710
- Timestamp:
- 19 Nov 2007, 20:29:10 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTool.py
r2704 r2710 445 445 security.declareProtected(View,'getCredential') ###( 446 446 def getCredential(self,student_id): 447 "return a student password"448 447 student_entry = getattr(self.portal_directories.students,student_id,None) 449 448 if not self.isStaff(): … … 458 457 ###) 459 458 460 security.declarePublic('checkPassword') ###(459 security.declarePublic('checkPassword') 461 460 def checkPassword(self,student_id,password): 462 "return a student password"463 461 student_entry = getattr(self.portal_directories.students,student_id,None) 464 462 if student_entry is None: 465 463 return False 466 464 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 468 474 469 475 security.declareProtected(ModifyPortalContent,'editPassword') ###( … … 1829 1835 if not validators[k](ds,mode=mode): 1830 1836 if error_count: 1831 error_string += ' ++ ' 1837 error_string += ' ++ ' 1832 1838 error_string += "%s: %s" % (k, 1833 1839 self.translation_service(ds.getError(k), -
WAeUP_SRP/base/Widgets.py
r2709 r2710 10 10 from Products.CMFCore.utils import getToolByName 11 11 from Products.CPSSchemas.BasicWidgets import CPSBooleanWidget, CPSWidget, CPSStringWidget, CPSEmailWidget,CPSImageWidget 12 from Products.CPSSchemas.BasicWidgets import CPSFileWidget 12 from Products.CPSSchemas.BasicWidgets import CPSFileWidget, CPSPasswordWidget 13 13 from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget 14 14 from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget … … 29 29 30 30 #from zLOG import LOG, DEBUG 31 32 33 class 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 116 InitializeClass(WAeUPPasswordWidget) 117 118 widgetRegistry.register(WAeUPPasswordWidget) 119 31 120 32 121 class CPSSelectWidgetForRecord(CPSSelectWidget): ###( -
WAeUP_SRP/base/skins/cps_custom/logged_in.py
r2579 r2710 36 36 is_anon = mtool.isAnonymousUser() 37 37 member = mtool.getAuthenticatedMember() 38 39 if 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 38 45 #load_passport = hasattr(context.waeup_tool,'loadStudentFoto') 39 46 … … 151 158 if s_review_state == "student_created": 152 159 wftool.doActionFor(student,'admit') 153 s_review_state = 'admitted' 160 s_review_state = 'admitted' 154 161 155 162 if s_review_state == "admitted" and a_review_state == 'created': -
WAeUP_SRP/uniben/profiles/default/layouts/members.xml
r1449 r2710 98 98 </property> 99 99 </widget> 100 <widget name="password" meta_type=" Password Widget">100 <widget name="password" meta_type="WAeUP Password Widget"> 101 101 <property name="fields"> 102 102 <element value="password"/>
Note: See TracChangeset for help on using the changeset viewer.