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, ), }
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), }
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()
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'), }
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()
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'), }
def schema(self, pyramid_request): return schemas.EmailChangeSchema().bind(request=pyramid_request)