Skip to content

Commit 5345d3c

Browse files
committed
Add Handlers Missing from Build Log
1 parent 163b711 commit 5345d3c

11 files changed

Lines changed: 212 additions & 6 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs password change events for security auditing purposes.
9+
/// </summary>
10+
public sealed class PasswordChangedLogHandler : INotificationHandler<PasswordChangedEvent>
11+
{
12+
private readonly ILogger<PasswordChangedLogHandler> _logger;
13+
14+
public PasswordChangedLogHandler(ILogger<PasswordChangedLogHandler> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public ValueTask Handle(PasswordChangedEvent notification, CancellationToken cancellationToken)
20+
{
21+
ArgumentNullException.ThrowIfNull(notification);
22+
23+
if (_logger.IsEnabled(LogLevel.Information))
24+
{
25+
_logger.LogInformation(
26+
"Password {Action} for user {UserId} in tenant {TenantId}",
27+
notification.WasReset ? "reset" : "changed",
28+
notification.UserId,
29+
notification.TenantId ?? "root");
30+
}
31+
32+
return ValueTask.CompletedTask;
33+
}
34+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs session revocation events for security auditing purposes.
9+
/// </summary>
10+
public sealed class SessionRevokedLogHandler : INotificationHandler<SessionRevokedEvent>
11+
{
12+
private readonly ILogger<SessionRevokedLogHandler> _logger;
13+
14+
public SessionRevokedLogHandler(ILogger<SessionRevokedLogHandler> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public ValueTask Handle(SessionRevokedEvent notification, CancellationToken cancellationToken)
20+
{
21+
ArgumentNullException.ThrowIfNull(notification);
22+
23+
if (_logger.IsEnabled(LogLevel.Information))
24+
{
25+
_logger.LogInformation(
26+
"Session {SessionId} revoked for user {UserId} in tenant {TenantId}. Reason: {Reason}",
27+
notification.SessionId,
28+
notification.UserId,
29+
notification.TenantId ?? "root",
30+
notification.RevokedBy);
31+
}
32+
33+
return ValueTask.CompletedTask;
34+
}
35+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs user activation events for auditing purposes.
9+
/// </summary>
10+
public sealed class UserActivatedLogHandler : INotificationHandler<UserActivatedEvent>
11+
{
12+
private readonly ILogger<UserActivatedLogHandler> _logger;
13+
14+
public UserActivatedLogHandler(ILogger<UserActivatedLogHandler> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public ValueTask Handle(UserActivatedEvent notification, CancellationToken cancellationToken)
20+
{
21+
ArgumentNullException.ThrowIfNull(notification);
22+
23+
if (_logger.IsEnabled(LogLevel.Information))
24+
{
25+
_logger.LogInformation(
26+
"User {UserId} activated in tenant {TenantId}",
27+
notification.UserId,
28+
notification.TenantId ?? "root");
29+
}
30+
31+
return ValueTask.CompletedTask;
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs user deactivation events for auditing purposes.
9+
/// </summary>
10+
public sealed class UserDeactivatedLogHandler : INotificationHandler<UserDeactivatedEvent>
11+
{
12+
private readonly ILogger<UserDeactivatedLogHandler> _logger;
13+
14+
public UserDeactivatedLogHandler(ILogger<UserDeactivatedLogHandler> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public ValueTask Handle(UserDeactivatedEvent notification, CancellationToken cancellationToken)
20+
{
21+
ArgumentNullException.ThrowIfNull(notification);
22+
23+
if (_logger.IsEnabled(LogLevel.Information))
24+
{
25+
_logger.LogInformation(
26+
"User {UserId} deactivated in tenant {TenantId}",
27+
notification.UserId,
28+
notification.TenantId ?? "root");
29+
}
30+
31+
return ValueTask.CompletedTask;
32+
}
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs user registration events for auditing purposes.
9+
/// Note: This is a domain event handler. There's also UserRegisteredEmailHandler
10+
/// which handles the integration event for cross-module communication.
11+
/// </summary>
12+
public sealed class UserRegisteredLogHandler : INotificationHandler<UserRegisteredEvent>
13+
{
14+
private readonly ILogger<UserRegisteredLogHandler> _logger;
15+
16+
public UserRegisteredLogHandler(ILogger<UserRegisteredLogHandler> logger)
17+
{
18+
_logger = logger;
19+
}
20+
21+
public ValueTask Handle(UserRegisteredEvent notification, CancellationToken cancellationToken)
22+
{
23+
ArgumentNullException.ThrowIfNull(notification);
24+
25+
if (_logger.IsEnabled(LogLevel.Information))
26+
{
27+
_logger.LogInformation(
28+
"User {UserId} ({Email}) registered in tenant {TenantId}",
29+
notification.UserId,
30+
notification.Email,
31+
notification.TenantId ?? "root");
32+
}
33+
34+
return ValueTask.CompletedTask;
35+
}
36+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FSH.Modules.Identity.Domain.Events;
2+
using Mediator;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace FSH.Modules.Identity.Events;
6+
7+
/// <summary>
8+
/// Logs user role assignment events for auditing purposes.
9+
/// </summary>
10+
public sealed class UserRoleAssignedLogHandler : INotificationHandler<UserRoleAssignedEvent>
11+
{
12+
private readonly ILogger<UserRoleAssignedLogHandler> _logger;
13+
14+
public UserRoleAssignedLogHandler(ILogger<UserRoleAssignedLogHandler> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public ValueTask Handle(UserRoleAssignedEvent notification, CancellationToken cancellationToken)
20+
{
21+
ArgumentNullException.ThrowIfNull(notification);
22+
23+
if (_logger.IsEnabled(LogLevel.Information))
24+
{
25+
var roles = string.Join(", ", notification.AssignedRoles);
26+
_logger.LogInformation(
27+
"Roles assigned to user {UserId} in tenant {TenantId}: {Roles}",
28+
notification.UserId,
29+
notification.TenantId ?? "root",
30+
roles);
31+
}
32+
33+
return ValueTask.CompletedTask;
34+
}
35+
}

src/Playground/Playground.Blazor/Components/Pages/Groups/CreateGroupDialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
{
229229
if (_form is not null)
230230
{
231-
await _form.Validate();
231+
await _form.ValidateAsync();
232232
if (!_form.IsValid)
233233
{
234234
return;

src/Playground/Playground.Blazor/Components/Pages/ProfileSettings.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ else
484484
{
485485
if (_profileForm is not null)
486486
{
487-
await _profileForm.Validate();
487+
await _profileForm.ValidateAsync();
488488
if (!_profileForm.IsValid)
489489
{
490490
Snackbar.Add("Please fix the validation errors.", Severity.Warning);
@@ -565,7 +565,7 @@ else
565565
{
566566
if (_passwordForm is not null)
567567
{
568-
await _passwordForm.Validate();
568+
await _passwordForm.ValidateAsync();
569569
if (!_passwordForm.IsValid)
570570
{
571571
Snackbar.Add("Please fix the validation errors.", Severity.Warning);

src/Playground/Playground.Blazor/Components/Pages/Roles/CreateRoleDialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
{
131131
if (_form is not null)
132132
{
133-
await _form.Validate();
133+
await _form.ValidateAsync();
134134
if (!_form.IsValid)
135135
{
136136
return;

src/Playground/Playground.Blazor/Components/Pages/Tenants/CreateTenantDialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
{
161161
if (_form is not null)
162162
{
163-
await _form.Validate();
163+
await _form.ValidateAsync();
164164
if (!_form.IsValid)
165165
{
166166
return;

0 commit comments

Comments
 (0)