Example #1
0
        public void SetUp()
        {
            securedEntityValidatorForSecuredEntity          = new SecuredEntityValidator <SecuredEntityWithTechnicalKey>();
            securedEntityValidatorForEntityThatIsNotSecured = new SecuredEntityValidator <object>();
            securedEntity = MockRepository.GenerateMock <SecuredEntityWithTechnicalKey>();
            currentUser   = new ApplicationUser();

            securedEntity.Expect(mock => mock.GamingGroupId)
            .Repeat.Any()
            .Return(securedEntityGamingGroupId);
        }
Example #2
0
        //TODO not sure how to enforce that TEntity is a SingleColumnWithTechnicalKey so I can get the Id, so requiring some
        //additional info to be manually passed in
        public virtual void ValidateAccess(TEntity entity, ApplicationUser currentUser, Type underlyingEntityType, object entityId)
        {
            SecuredEntityWithTechnicalKey securedEntity = entity as SecuredEntityWithTechnicalKey;

            if (securedEntity == null)
            {
                return;
            }

            ValidateArguments(currentUser);

            if (securedEntity.GamingGroupId != currentUser.CurrentGamingGroupId)
            {
                throw new UnauthorizedEntityAccessException(currentUser.Id, underlyingEntityType, entityId);
            }
        }