/// <summary> /// Ensures the owner of the entity matches /// </summary> /// <param name="entity"></param> /// <param name="ownerId"></param> public void EnsureOwner(IAppOwnerEntity entity, int ownerId) { if (entity.Owner.Id != ownerId) { throw new SecurityException($"Owner Id {entity.Owner.Id} <-> {ownerId} doesn't match"); } }
/// <summary> /// Ensures the owner of the entity matches /// </summary> /// <param name="entity"></param> /// <param name="ownerId"></param> public void EnsureOwner(IAppOwnerEntity entity, int ownerId) { if (entity.Owner.Id != ownerId) { throw new HttpResponseException(HttpStatusCode.Forbidden); } }
/// <summary> /// Assigns an owner to the specified entity /// </summary> /// <param name="entity"></param> /// <param name="ownerId"></param> public void AssignOwner(IAppOwnerEntity entity, int ownerId) { AppOwner owner = this._appOwnerRepository.FindById(ownerId); Debug.Assert(owner != null); entity.Owner = owner; }
private void VerifyOwnership(IAppOwnerEntity appOwnerEntity) { if (appOwnerEntity == null) { return; } int appOwnerId = GetAppOwnerId(this._httpContext); this._entityOwnerService.EnsureOwner(appOwnerEntity, appOwnerId); }