Exemplo n.º 1
0
    def auth_validator(form, value):
        """
        Authentication validator

        :param obj form: The form object
        :param dict value: The submitted datas to validate
        :raises: colander.Invalid on invalid authentication
        """
        logger.debug(u" * Authenticating")
        if current_login_object is None:
            login = value.get('login')
            login_object = Login.find_by_login(login)
            logger.debug(u"   +  Login {0}".format(login))
        else:
            login_object = current_login_object
            logger.debug(u"   +  Login {0}".format(login_object.login))

        password = value.get('password')
        if not login_object or not login_object.auth(password):
            logger.error(u"    - Authentication : Error")
            message = u"Erreur d'authentification"
            exc = colander.Invalid(form, message)
            exc['password'] = message
            raise exc
        else:
            logger.debug(u"   + Authentication : OK")
Exemplo n.º 2
0
    def auth_validator(form, value):
        """
        Authentication validator

        :param obj form: The form object
        :param dict value: The submitted datas to validate
        :raises: colander.Invalid on invalid authentication
        """
        logger.debug(u" * Authenticating")
        if current_login_object is None:
            login = value.get('login')
            login_object = Login.find_by_login(login)
            logger.debug(u"   +  Login {0}".format(login))
        else:
            login_object = current_login_object
            logger.debug(u"   +  Login {0}".format(login_object.login))

        password = value.get('password')
        if not login_object or not login_object.auth(password):
            logger.error(u"    - Authentication : Error")
            message = u"Erreur d'authentification"
            exc = colander.Invalid(form, message)
            exc['password'] = message
            raise exc
        else:
            logger.debug(u"   + Authentication : OK")
Exemplo n.º 3
0
def test_find_by_login(dbsession, login):
    assert Login.find_by_login(login.login).id == login.id
Exemplo n.º 4
0
def test_find_by_login(dbsession, login):
    assert Login.find_by_login(login.login).id == login.id