Ejemplo n.º 1
0
        internal void RefreshSessionAndClearCache(System.Guid userId)
        {
            var sessionPattern = IdUtils.CreateUrn <ServiceStack.Auth.IAuthSession>(string.Empty); //= urn:iauthsession:
            var sessionKeys    = Cache.GetKeysStartingWith(sessionPattern).ToList();

            if (sessionKeys.Any())
            {
                var allSessions = Cache.GetAll <ServiceModel.Office.EsamSession>(sessionKeys);
                foreach (var ses in allSessions.Where(x => x.Value.UserIdGuid == userId))
                {
                    Repository.Cache.Remove($"sessions:{ses.Value.Id}:pfe:UserTenants");
                    if (ses.Value.AdminLevel != AdminLevel.SysAdmin)
                    {
                        ServerEvents.NotifySession(ses.Value.Id, new ServiceModel.Office.Dto.ContextChangedDto {
                            Changed = true
                        });
                        Request.RemoveSession(ses.Value.Id);
                    }
                }
            }
        }