Ejemplo n.º 1
0
        private void HandleEvent(IActorRef _, ClaimsRemoved evt)
        {
            var claimsToRemove = user.Claims.Intersect(evt.ClaimsToRemove, ClaimComparer.Instance).ToList();

            foreach (var claim in claimsToRemove)
            {
                user.Claims.Remove(claim);
            }
            coordinator.Tell(new ActorMessages.UserCoordinator.NotifyUserEvent(new ActorMessages.UserCoordinator.UserClaimsRemoved <TKey>(userId, claimsToRemove)));
        }
Ejemplo n.º 2
0
        public void TestSerializationOfClaimsRemoved()
        {
            var evt = new ClaimsRemoved(new[] { new Claim("type1", "value1"), new Claim("type2", "value2") });

            var bytes    = LZ4MessagePackSerializer.Serialize <IEvent>(evt, AspnetIdentityResolver.Instance);
            var eventChk = LZ4MessagePackSerializer.Deserialize <IEvent>(bytes, AspnetIdentityResolver.Instance) as ClaimsRemoved;

            Assert.NotNull(eventChk);
            var evtClaims      = evt.ClaimsToRemove.ToArray();
            var eventChkClaims = eventChk.ClaimsToRemove.ToArray();

            Assert.Equal(evtClaims.Length, eventChkClaims.Length);
            for (int i = 0; i < evtClaims.Length; i++)
            {
                Assert.Equal(evtClaims[i].Type, eventChkClaims[i].Type);
                Assert.Equal(evtClaims[i].Value, eventChkClaims[i].Value);
            }
        }
Ejemplo n.º 3
0
        private bool TestCommand(RemoveClaims evt, out IEvent e)
        {
            e = null;
            if (user == null)
            {
                return(false);
            }

            if (user.Claims == null)
            {
                return(true);
            }

            var claimsToRemove = user.Claims.Intersect(evt.Claims, ClaimComparer.Instance).ToList();

            if (claimsToRemove.Count > 0)
            {
                e = new ClaimsRemoved(claimsToRemove);
            }

            return(true);
        }