Changeset 5818 for main/waeup.sirp/trunk/src
- Timestamp:
- 8 Mar 2011, 02:33:18 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py
r5806 r5818 28 28 from zope.pluggableauth.factories import Principal 29 29 from zope.pluggableauth.interfaces import ( 30 ICredentialsPlugin, IAuthenticatorPlugin, IPrincipalInfo,30 ICredentialsPlugin, IAuthenticatorPlugin, 31 31 IAuthenticatedPrincipalFactory, AuthenticatedPrincipalCreated) 32 32 from zope.pluggableauth.plugins.session import SessionCredentialsPlugin … … 34 34 from zope.publisher.interfaces.http import IHTTPRequest 35 35 from zope.session.interfaces import ISession 36 from waeup.sirp.a uthentication import Account, PrincipalInfo36 from waeup.sirp.accesscodes import get_access_code 37 37 from waeup.sirp.applicants.interfaces import ( 38 38 IApplicantPrincipalInfo, IApplicantPrincipal, IApplicantSessionCredentials, 39 39 IJAMBApplicantSessionCredentials) 40 from waeup.sirp.applicants import ( 41 get_applicant_data, application_exists, 42 ) 43 from waeup.sirp.accesscodes import get_access_code 40 from waeup.sirp.applicants import get_applicant_data 41 44 42 45 43 class PortalUser(grok.Role): … … 54 52 grok.implements(IApplicantPrincipalInfo) 55 53 56 def __init__(self, access_code , jamb_reg_no=None):57 self.id = principal_id(access_code , jamb_reg_no)54 def __init__(self, access_code): 55 self.id = principal_id(access_code) 58 56 self.title = u'Applicant' 59 57 self.description = u'An Applicant' 60 58 self.credentialsPlugin = None 61 59 self.authenticatorPlugin = None 62 self.reg_no = jamb_reg_no63 60 self.access_code = access_code 64 61 … … 72 69 grok.implements(IApplicantPrincipal) 73 70 74 def __init__(self, access_code, reg_no,prefix=None):75 self.id = principal_id(access_code , reg_no)71 def __init__(self, access_code, prefix=None): 72 self.id = principal_id(access_code) 76 73 if prefix is not None: 77 74 self.id = '%s.%s' % (prefix, self.id) … … 79 76 self.description = u'An applicant' 80 77 self.groups = [] 81 self.reg_no = reg_no82 78 self.access_code = access_code 83 79 … … 103 99 principal = ApplicantPrincipal( 104 100 self.info.access_code, 105 self.info.reg_no,106 101 authentication.prefix, 107 102 ) … … 144 139 grok.implements(IJAMBApplicantSessionCredentials) 145 140 146 def __init__(self, access_code, jamb_reg_no): 147 self.access_code = access_code 148 self.jamb_reg_no = jamb_reg_no 149 150 def getJAMBRegNo(self): 151 """Get the JAMB registration no. 152 """ 153 return self.jamb_reg_no 141 def __init__(self, access_code): 142 self.access_code = access_code 154 143 155 144 class WAeUPApplicantCredentialsPlugin(grok.GlobalUtility, … … 164 153 accesscode_series_field = 'form.ac_series' 165 154 accesscode_number_field = 'form.ac_number' 166 jamb_reg_no_field = 'form.jamb_reg_no'167 155 168 156 def extractCredentials(self, request): … … 177 165 access_code_series = request.get(self.accesscode_series_field, None) 178 166 access_code_no = request.get(self.accesscode_number_field, None) 179 jamb_reg_no = request.get(self.jamb_reg_no_field, None)180 167 access_code = '%s-%s-%s' % ( 181 168 access_code_prefix, access_code_series, access_code_no) … … 184 171 credentials = None 185 172 186 if access_code and jamb_reg_no: 187 credentials = JAMBApplicantCredentials( 188 access_code, jamb_reg_no) 189 elif access_code: 173 if access_code: 190 174 credentials = ApplicantCredentials(access_code) 191 175 elif not sessionData: … … 204 188 # its structure. 205 189 return None 206 if not IJAMBApplicantSessionCredentials.providedBy(credentials): 207 # Entered credentials are ordinary applicant credentials, 208 # not JAMB-screened applicant credentials 209 return {'accesscode': credentials.getAccessCode()} 210 return {'accesscode': credentials.getAccessCode(), 211 'jambregno': credentials.getJAMBRegNo()} 190 191 # Entered credentials are ordinary applicant credentials, 192 # not JAMB-screened applicant credentials 193 return {'accesscode': credentials.getAccessCode()} 212 194 213 195 … … 226 208 return None 227 209 accesscode = credentials.get('accesscode', None) 228 jambregno = credentials.get('jambregno', None)229 210 if accesscode is None: 230 211 return None 231 applicant_data, ac = get_applicant_data(jambregno, accesscode) 212 applicant_data = get_applicant_data(accesscode) 213 ac = get_access_code(accesscode) # Get the real access code object 232 214 appl_ac = getattr(applicant_data, 'access_code', None) 233 #print "AUTH", accesscode, jambregno234 215 if ac is None: 235 216 return None 236 if jambregno is not None and applicant_data is None:237 return None238 217 if ac.invalidation_date is not None and appl_ac != ac.representation: 239 218 return None 240 219 if appl_ac is not None and appl_ac != ac.representation: 241 220 return None 242 return ApplicantPrincipalInfo(accesscode , jambregno)221 return ApplicantPrincipalInfo(accesscode) 243 222 244 223 def principalInfo(self, id): … … 254 233 return None 255 234 256 def principal_id(access_code , jamb_reg_no=None):235 def principal_id(access_code): 257 236 """Get a principal ID for applicants. 258 237
Note: See TracChangeset for help on using the changeset viewer.