Esempio n. 1
0
    def __init__(self, request):
        self.request = request

        email_schema = schemas.EmailChangeSchema().bind(request=request)
        password_schema = schemas.PasswordChangeSchema().bind(request=request)

        # Ensure deform generates unique field IDs for each field in this
        # multiple-form page.
        counter = itertools.count()

        self.forms = {
            "email":
            request.create_form(
                email_schema,
                buttons=(_("Save"), ),
                formid="email",
                counter=counter,
                use_inline_editing=True,
            ),
            "password":
            request.create_form(
                password_schema,
                buttons=(_("Save"), ),
                formid="password",
                counter=counter,
                use_inline_editing=True,
            ),
        }
Esempio n. 2
0
    def __init__(self, request):
        self.request = request

        if request.feature('activity_pages'):
            email_schema = schemas.EmailChangeSchema().bind(request=request)
        else:
            email_schema = schemas.LegacyEmailChangeSchema().bind(
                request=request)

        password_schema = schemas.PasswordChangeSchema().bind(request=request)

        # Ensure deform generates unique field IDs for each field in this
        # multiple-form page.
        counter = itertools.count()

        self.forms = {
            'email':
            request.create_form(email_schema,
                                buttons=(_('Change email address'), ),
                                formid='email',
                                counter=counter),
            'password':
            request.create_form(password_schema,
                                buttons=(_('Change password'), ),
                                formid='password',
                                counter=counter),
        }
Esempio n. 3
0
def test_EmailChangeSchema_rejects_non_matching_emails(config, user_model):
    user = Mock()
    request = csrf_request(config, authenticated_user=user)
    schema = schemas.EmailChangeSchema().bind(request=request)
    # The email isn't taken
    user_model.get_by_email.return_value = None

    with pytest.raises(colander.Invalid) as exc:
        schema.deserialize({'email': '*****@*****.**',
                            'email_confirm': '*****@*****.**',
                            'password': '******'})

    assert 'email_confirm' in exc.value.asdict()
Esempio n. 4
0
    def __init__(self, request):
        self.request = request

        email_schema = schemas.EmailChangeSchema().bind(request=request)
        password_schema = schemas.PasswordChangeSchema().bind(request=request)

        self.forms = {
            'email': deform.Form(email_schema,
                                 buttons=(_('Change email address'),),
                                 formid='email'),
            'password': deform.Form(password_schema,
                                    buttons=(_('Change password'),),
                                    formid='password'),
        }
Esempio n. 5
0
def test_EmailChangeSchema_rejects_wrong_password(config, user_model):
    user = Mock()
    request = csrf_request(config, authenticated_user=user)
    schema = schemas.EmailChangeSchema().bind(request=request)
    # The email isn't taken
    user_model.get_by_email.return_value = None
    # The password does not check out
    user_model.validate_user.return_value = False

    with pytest.raises(colander.Invalid) as exc:
        schema.deserialize({'email': '*****@*****.**',
                            'email_confirm': '*****@*****.**',
                            'password': '******'})

    user_model.validate_user.assert_called_once_with(user, 'flibble')
    assert 'password' in exc.value.asdict()
Esempio n. 6
0
File: views.py Progetto: rmoorman/h
    def __init__(self, request):
        self.request = request

        if request.feature('activity_pages'):
            email_schema = schemas.EmailChangeSchema().bind(request=request)
        else:
            email_schema = schemas.LegacyEmailChangeSchema().bind(request=request)

        password_schema = schemas.PasswordChangeSchema().bind(request=request)

        self.forms = {
            'email': request.create_form(email_schema,
                                         buttons=(_('Change email address'),),
                                         formid='email'),
            'password': request.create_form(password_schema,
                                            buttons=(_('Change password'),),
                                            formid='password'),
        }
Esempio n. 7
0
 def schema(self, pyramid_request):
     return schemas.EmailChangeSchema().bind(request=pyramid_request)