Beispiel #1
0
        public void Confirm(Guid correlationId)
        {
            correlationId = new AccountCorrelationId(correlationId);
            Confirmed     = true;
            ChangeSecurityStamp(correlationId);
            var token = _tokens.SingleOrDefault(x => x.Type.Equals(TokenTypeEnumeration.AccountConfirmation));

            _tokens.Remove(token);
            AddEvent(new AccountConfirmedDomainEvent(Id, correlationId));
        }
Beispiel #2
0
        public void RemoveRole(Guid role, Guid correlationId)
        {
            role          = new AccountRole(role);
            correlationId = new AccountCorrelationId(correlationId);

            if (_roles.Contains(role))
            {
                _roles.Remove(role);
                AddEvent(new AccountRoleDeletedDomainEvent(Id, correlationId, role));
            }
        }
Beispiel #3
0
        public void AddRole(Guid role, Guid correlationId)
        {
            role          = new AccountRole(role);
            correlationId = new AccountCorrelationId(correlationId);
            var anyDuplicates = _roles.Any(x => x == role);

            if (!anyDuplicates)
            {
                _roles.Add(role);
                AddEvent(new AccountRoleAddedDomainEvent(Id, correlationId, role));
            }
        }
Beispiel #4
0
        public Token GenerateToken(TokenTypeEnumeration tokenType, Guid correlationId)
        {
            tokenType     = new TokenType(tokenType);
            correlationId = new AccountCorrelationId(correlationId);
            var token = _tokens.SingleOrDefault(x => x.Type.Equals(tokenType));

            _tokens.Remove(token);
            ChangeSecurityStamp(correlationId);
            token = _tokenGeneratorService.Generate(Id, SecurityStamp, tokenType);
            _tokens.Add(token);
            AddEvent(new AccountTokenGeneratedDomainEvent(Id, correlationId, token));
            return(token);
        }
Beispiel #5
0
 public void Login(Guid correlationId)
 {
     correlationId = new AccountCorrelationId(correlationId);
     LastLogin     = DateTimeOffset.UtcNow;
     AddEvent(new AccountLoggedInDomainEvent(Id, correlationId, LastLogin.Value));
 }
Beispiel #6
0
 public void AddDeletedEvent(Guid correlationId)
 {
     correlationId = new AccountCorrelationId(correlationId);
     AddEvent(new AccountDeletedDomainEvent(Id, correlationId));
 }
Beispiel #7
0
 public void AddCreatedEvent(Guid correlationId)
 {
     correlationId = new AccountCorrelationId(correlationId);
     AddEvent(new AccountCreatedDomainEvent(Id, correlationId, Email, Confirmed, PasswordHash, SecurityStamp,
                                            Created, LastLogin));
 }
Beispiel #8
0
 private void ChangeSecurityStamp(Guid correlationId)
 {
     SecurityStamp = Guid.NewGuid();
     correlationId = new AccountCorrelationId(correlationId);
     AddEvent(new AccountSecurityStampChangedDomainEvent(Id, correlationId, SecurityStamp));
 }