Ignore:
Timestamp:
15 Oct 2012, 05:08:01 (12 years ago)
Author:
Henrik Bettermann
Message:

ApplicantAccount? can't reuse checkPassword.

Add new role and permission.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/authentication.py

    r7811 r9335  
    2020"""
    2121import grok
     22from zope.component import getUtility
     23from zope.password.interfaces import IPasswordManager
    2224from zope.pluggableauth.interfaces import IAuthenticatorPlugin
    2325from waeup.kofa.interfaces import IAuthPluginUtility, IUserAccount
     
    4345    def user_type(self):
    4446        return u'applicant'
     47
     48    def checkPassword(self, password):
     49        """Check whether the given `password` matches the one stored by
     50        students.
     51
     52        We additionally check if student account has been suspended.
     53        """
     54        if not isinstance(password, basestring):
     55            return False
     56        passwordmanager = getUtility(IPasswordManager, 'SSHA')
     57        if not getattr(self.context, 'password', None):
     58            # unset/empty passwords do never match
     59            return False
     60        if self.context.suspended == True:
     61            return False
     62        return passwordmanager.checkPassword(self.context.password, password)
    4563
    4664class ApplicantsAuthenticatorPlugin(StudentsAuthenticatorPlugin):
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.py

    r9309 r9335  
    224224                     'waeup.handleAccommodation',
    225225                     'waeup.viewHostels', 'waeup.manageHostels',
    226                      'waeup.editUser'
     226                     'waeup.editUser',
     227                     'waeup.loginAsStudent'
    227228                     )
    228229
     
    250251                     'waeup.handleAccommodation',
    251252                     'waeup.viewHostels', 'waeup.manageHostels',
    252                      #'waeup.editUser'
     253                     #'waeup.editUser',
     254                     #'waeup.loginAsStudent'
    253255                     )
    254256
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt

    r9309 r9335  
    3939    >>> from waeup.kofa.permissions import get_waeup_roles
    4040    >>> len(list(get_waeup_roles()))
    41     17
     41    18
    4242
    4343    >>> len(list(get_waeup_roles(also_local=True)))
    44     31
     44    32
    4545
    4646
     
    6464     u'waeup.PortalManager',
    6565     u'waeup.Student',
     66     u'waeup.StudentImpersonator',
    6667     u'waeup.StudentsClearanceOfficer',
    6768     u'waeup.StudentsCourseAdviser',
  • main/waeup.kofa/trunk/src/waeup/kofa/students/permissions.py

    r9273 r9335  
    5959    grok.name('waeup.triggerTransition')
    6060
     61class LoginAsStudent(grok.Permission):
     62    grok.name('waeup.loginAsStudent')
     63
    6164# Local role
    6265class StudentRecordOwner(grok.Role):
     
    9699    grok.title(u'Course Adviser (all students)')
    97100    grok.permissions('waeup.validateStudent','waeup.viewStudent')
     101
     102class StudentImpersonator(grok.Role):
     103    grok.name('waeup.StudentImpersonator')
     104    grok.title(u'Student Impersonator')
     105    grok.permissions('waeup.loginAsStudent')
Note: See TracChangeset for help on using the changeset viewer.