-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from ministryofjustice/develop
Develop
- Loading branch information
Showing
152 changed files
with
28,058 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Cfo.Cats.Infrastructure.Constants; | ||
|
||
public static class Documents | ||
{ | ||
public static class Consent | ||
{ | ||
public const double MaximumSizeInMegabytes = 5; | ||
|
||
public static IReadOnlyList<string> Versions { get; set; } = | ||
[ | ||
"1.0" | ||
]; | ||
} | ||
|
||
public static class RightToWork | ||
{ | ||
public const double MaximumSizeInMegabytes = 5; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Application/Features/Identity/DTOs/IdentityAuditTrailDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Cfo.Cats.Application.Features.Identity.DTOs | ||
{ | ||
public class IdentityAuditTrailDto | ||
{ | ||
|
||
[Description("User Name")] | ||
public string? UserName { get; set; } | ||
|
||
[Description("Performed By")] | ||
public string? PerformedBy { get; set; } | ||
|
||
[Description("Date Time")] | ||
public DateTime DateTime { get; set; } | ||
|
||
[Description("Action Type")] | ||
public IdentityActionType? ActionType { get;set; } | ||
|
||
private class Mapping : Profile | ||
{ | ||
public Mapping() | ||
{ | ||
CreateMap<IdentityAuditTrail, IdentityAuditTrailDto>(); | ||
} | ||
} | ||
|
||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/Application/Features/Identity/Notifications/IdentityEvents/IdentityAuditNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Cfo.Cats.Application.Features.Identity.Notifications.IdentityEvents; | ||
|
||
public class IdentityAuditNotification : INotification | ||
{ | ||
|
||
private IdentityAuditNotification(IdentityActionType actionType, string? userName = null, string? performedBy = null) | ||
{ | ||
ActionType = actionType; | ||
UserName = userName; | ||
PerformedBy = performedBy ?? userName; | ||
} | ||
|
||
public IdentityActionType ActionType { get; private set; } | ||
|
||
public string? UserName { get; private set; } | ||
|
||
public string? PerformedBy { get; private set; } | ||
|
||
public static IdentityAuditNotification UnknownUserNameNotification(string userName) | ||
=> new (IdentityActionType.UnknownUser, userName); | ||
|
||
public static IdentityAuditNotification LoginFailedPassword(string userName) | ||
=> new (IdentityActionType.IncorrectPasswordEntered, userName, null); | ||
public static IdentityAuditNotification LoginFailedTwoFactor(string userName) | ||
=> new (IdentityActionType.IncorrectTwoFactorCodeEntered, userName, null); | ||
|
||
public static IdentityAuditNotification LoginSucceededNoTwoFactorRequired(string userName) | ||
=> new(IdentityActionType.LoginPasswordOnly, userName); | ||
|
||
public static IdentityAuditNotification LoginSucceededTwoFactorRequired(string userName) | ||
=> new(IdentityActionType.LoginWithTwoFactorCode, userName); | ||
|
||
public static IdentityAuditNotification UserLockedOut(string userName) | ||
=> new(IdentityActionType.UserAccountLockedOut, userName); | ||
|
||
public static IdentityAuditNotification PasswordReset(string userName, string? performedBy = null) | ||
=> new(IdentityActionType.PasswordReset, userName, performedBy); | ||
|
||
public static IdentityAuditNotification ActivateAccount(string userName, string performedBy) | ||
=> new(IdentityActionType.AccountActivated, userName, performedBy); | ||
|
||
public static IdentityAuditNotification DeactivateAccount(string userName, string performedBy) | ||
=> new(IdentityActionType.AccountDeactivated, userName, performedBy); | ||
|
||
} | ||
|
16 changes: 16 additions & 0 deletions
16
...cation/Features/Identity/Notifications/IdentityEvents/IdentityAuditNotificationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Cfo.Cats.Application.Features.Identity.Notifications.IdentityEvents; | ||
|
||
public class IdentityAuditNotificationHandler(IUnitOfWork unitOfWork) : INotificationHandler<IdentityAuditNotification> | ||
{ | ||
public async Task Handle(IdentityAuditNotification notification, CancellationToken cancellationToken) | ||
{ | ||
IdentityAuditTrail audit = IdentityAuditTrail.Create(notification.UserName, notification.PerformedBy, notification.ActionType); | ||
unitOfWork.DbContext.IdentityAuditTrails.Add(audit); | ||
await unitOfWork.SaveChangesAsync(cancellationToken); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...ures/Identity/Notifications/SendTwoFactorCode/SendTwoFactorTextCodeNotificationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace Cfo.Cats.Application.Features.Identity.Notifications.SendTwoFactorCode; | ||
|
||
public class SendTwoFactorTextCodeNotificationHandler(ICommunicationsService communicationsService, ILogger<SendTwoFactorTextCodeNotificationHandler> logger) | ||
public class SendTwoFactorTextCodeNotificationHandler(ICommunicationsService communicationsService) | ||
: INotificationHandler<SendTwoFactorTextCodeNotification> | ||
{ | ||
public async Task Handle(SendTwoFactorTextCodeNotification notification, CancellationToken cancellationToken) | ||
{ | ||
await communicationsService.SendSmsCodeAsync(notification.MobileNumber, notification.AuthenticatorCode); | ||
logger.LogDebug("Verification Code email sent to {UserName})", notification.UserName); | ||
} | ||
} |
Oops, something went wrong.