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.

File:
1 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):
Note: See TracChangeset for help on using the changeset viewer.