Exemplo n.º 1
0
        private async Task CheckOwnershipOrSysAdminAsync(IOwnedEntity entity, EntityHeader org, EntityHeader user, [CallerMemberName] string actionType = "")
        {
            if (entity.OwnerOrganization.Id != org.Id)
            {
                var sysUser = await _userManager.FindByIdAsync(user.Id);

                if (sysUser.IsSystemAdmin)
                {
                    await LogEntityActionAsync(entity.Id, entity.GetType().Name, $"sys_admin=>{actionType}", org, user);
                }
                else
                {
                    await AuthorizeAsync(entity, AuthorizeResult.AuthorizeActions.Read, user, org, actionType);
                }
            }
            else
            {
                await AuthorizeAsync(entity, AuthorizeResult.AuthorizeActions.Read, user, org, actionType);
            }
        }
Exemplo n.º 2
0
 protected Task AuthorizeAsync(IOwnedEntity ownedEntity, AuthorizeActions action, EntityHeader user, EntityHeader org, String actionName = null)
 {
     return(_security.AuthorizeAsync(ownedEntity, action, user, org, actionName));
 }
Exemplo n.º 3
0
 protected void SetOwnedProperties(IOwnedEntity entity)
 {
     entity.OwnerOrganization = OrgEntityHeader;
 }
Exemplo n.º 4
0
 protected void AddOwnedProperties(IOwnedEntity entity, EntityHeader org)
 {
     entity.OwnerOrganization = org;
     entity.IsPublic          = false;
 }