def get_principal_by_login(self, login): try: return principalRegistry.getPrincipalByLogin(login) except PrincipalLookupError: pass except KeyError: pass
def authenticateCredentials(self, credentials): """Return principal info if credentials can be authenticated """ if not isinstance(credentials, dict): return None if not ('login' in credentials and 'password' in credentials): return None principal = None login, password = credentials['login'], credentials['password'] try: principal = principalRegistry.getPrincipalByLogin(login) except KeyError: return if principal and principal.validate(password): return PrincipalInfo(u'' + principal.id, principal.getLogin(), principal.title, principal.description) return