/// <summary> /// Updates any Cache Objects that are associated with this entity /// </summary> /// <param name="entityState">State of the entity.</param> /// <param name="dbContext">The database context.</param> public void UpdateCache(System.Data.Entity.EntityState entityState, Rock.Data.DbContext dbContext) { var group = this.Group ?? new GroupService(new RockContext()).GetNoTracking(this.GroupId); if (group != null) { var groupType = GroupTypeCache.Get(group.GroupTypeId, (RockContext)dbContext); if (group.IsSecurityRole || groupType?.Guid == Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid()) { RoleCache.FlushItem(group.Id); Rock.Security.Authorization.Clear(); } } }
/// <summary> /// Updates any Cache Objects that are associated with this entity /// </summary> /// <param name="entityState">State of the entity.</param> /// <param name="dbContext">The database context.</param> public void UpdateCache(System.Data.Entity.EntityState entityState, Rock.Data.DbContext dbContext) { // If the group changed, and it was a security group, flush the security for the group Guid?originalGroupTypeGuid = null; Guid groupTypeScheduleRole = Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid(); if (_originalGroupTypeId.HasValue && _originalGroupTypeId != this.GroupTypeId) { originalGroupTypeGuid = GroupTypeCache.Get(_originalGroupTypeId.Value, (RockContext)dbContext)?.Guid; } var groupTypeGuid = GroupTypeCache.Get(this.GroupTypeId, (RockContext)dbContext)?.Guid; if (this.IsSecurityRole || (_originalIsSecurityRole == true) || (groupTypeGuid == groupTypeScheduleRole) || (originalGroupTypeGuid == groupTypeScheduleRole)) { RoleCache.FlushItem(this.Id); } }