public FailedLoginAuditMessage(string emailAddress, User user) { Category = "FAILED_LOGIN"; AffectedEntity = new Audit.Types.Entity { Type = UserTypeName, Id = user.Id }; Description = $"User {user.Email} (id: {user.Id})attempted to login with the incorrect password"; ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromInt(nameof(user.FailedLoginAttempts), user.FailedLoginAttempts) }; }
public AccountLockedAuditMessage(User user) { Category = "ACCOUNT_LOCKED"; Description = $"User {user.Email} (id: {user.Id}) has exceeded the limit of failed logins and the account has been locked"; AffectedEntity = new Entity { Type = UserTypeName, Id = user.Id }; ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromInt(nameof(user.FailedLoginAttempts), user.FailedLoginAttempts), PropertyUpdate.FromBool(nameof(user.IsLocked), user.IsLocked) }; }
public UnlockedAuditMessage(User user) { AffectedEntity = new Entity { Type = UserTypeName, Id = user.Id }; Category = "UNLOCK"; Description = $"User {user.Email} (id: {user.Id}) unlocked their account"; ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromBool(nameof(user.IsLocked), user.IsLocked), PropertyUpdate.FromInt(nameof(user.FailedLoginAttempts), user.FailedLoginAttempts) }; }
private async Task CreateAuditEntries(CreateAccountCommand message, CreateAccountResult returnValue, string hashedAccountId, User user) { //Account await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"Account {message.OrganisationName} created with id {returnValue.AccountId}", ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromLong("AccountId", returnValue.AccountId), PropertyUpdate.FromString("HashedId", hashedAccountId), PropertyUpdate.FromString("Name", message.OrganisationName), PropertyUpdate.FromDateTime("CreatedDate", DateTime.UtcNow), }, AffectedEntity = new Entity { Type = "Account", Id = returnValue.AccountId.ToString() }, RelatedEntities = new List <Entity>() } }); //LegalEntity var changedProperties = new List <PropertyUpdate> { PropertyUpdate.FromLong("Id", returnValue.LegalEntityId), PropertyUpdate.FromString("Name", message.OrganisationName), PropertyUpdate.FromString("Code", message.OrganisationReferenceNumber), PropertyUpdate.FromString("RegisteredAddress", message.OrganisationAddress), PropertyUpdate.FromString("OrganisationType", message.OrganisationType.ToString()), PropertyUpdate.FromString("PublicSectorDataSource", message.PublicSectorDataSource.ToString()), PropertyUpdate.FromString("Sector", message.Sector) }; if (message.OrganisationDateOfInception != null) { changedProperties.Add(PropertyUpdate.FromDateTime("DateOfIncorporation", message.OrganisationDateOfInception.Value)); } await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"Legal Entity {message.OrganisationName} created of type {message.OrganisationType} with id {returnValue.LegalEntityId}", ChangedProperties = changedProperties, AffectedEntity = new Entity { Type = "LegalEntity", Id = returnValue.LegalEntityId.ToString() }, RelatedEntities = new List <Entity>() } }); //EmployerAgreement await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"Employer Agreement Created for {message.OrganisationName} legal entity id {returnValue.LegalEntityId}", ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromLong("Id", returnValue.EmployerAgreementId), PropertyUpdate.FromLong("LegalEntityId", returnValue.LegalEntityId), PropertyUpdate.FromString("TemplateId", hashedAccountId), PropertyUpdate.FromInt("StatusId", 2), }, RelatedEntities = new List <Entity> { new Entity { Id = returnValue.EmployerAgreementId.ToString(), Type = "LegalEntity" } }, AffectedEntity = new Entity { Type = "EmployerAgreement", Id = returnValue.EmployerAgreementId.ToString() } } }); //AccountEmployerAgreement Account Employer Agreement await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"Employer Agreement Created for {message.OrganisationName} legal entity id {returnValue.LegalEntityId}", ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromLong("AccountId", returnValue.AccountId), PropertyUpdate.FromLong("EmployerAgreementId", returnValue.EmployerAgreementId), }, RelatedEntities = new List <Entity> { new Entity { Id = returnValue.EmployerAgreementId.ToString(), Type = "LegalEntity" }, new Entity { Id = returnValue.AccountId.ToString(), Type = "Account" } }, AffectedEntity = new Entity { Type = "AccountEmployerAgreement", Id = returnValue.EmployerAgreementId.ToString() } } }); //Paye await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"Paye scheme {message.PayeReference} added to account {returnValue.AccountId}", ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromString("Ref", message.PayeReference), PropertyUpdate.FromString("AccessToken", message.AccessToken), PropertyUpdate.FromString("RefreshToken", message.RefreshToken), PropertyUpdate.FromString("Name", message.EmployerRefName) }, RelatedEntities = new List <Entity> { new Entity { Id = returnValue.AccountId.ToString(), Type = "Account" } }, AffectedEntity = new Entity { Type = "Paye", Id = message.PayeReference } } }); //Membership Account await _mediator.SendAsync(new CreateAuditCommand { EasAuditMessage = new EasAuditMessage { Category = "CREATED", Description = $"User {message.ExternalUserId} added to account {returnValue.AccountId} as owner", ChangedProperties = new List <PropertyUpdate> { PropertyUpdate.FromLong("AccountId", returnValue.AccountId), PropertyUpdate.FromString("UserId", message.ExternalUserId), PropertyUpdate.FromString("RoleId", Role.Owner.ToString()), PropertyUpdate.FromDateTime("CreatedDate", DateTime.UtcNow) }, RelatedEntities = new List <Entity> { new Entity { Id = returnValue.AccountId.ToString(), Type = "Account" }, new Entity { Id = user.Id.ToString(), Type = "User" } }, AffectedEntity = new Entity { Type = "Membership", Id = message.ExternalUserId } } }); }