Endpoints #3
@@ -5,7 +5,7 @@ using PostFundManagement.Domain.Abstractions;
|
|||||||
using PostFundManagement.Domain.Api;
|
using PostFundManagement.Domain.Api;
|
||||||
using PostFundManagement.Domain.Extensions;
|
using PostFundManagement.Domain.Extensions;
|
||||||
using PostFundManagement.Domain.Models;
|
using PostFundManagement.Domain.Models;
|
||||||
using static PostFundManagement.Domain.Extensions.General;
|
using static PostFundManagement.Application.Extensions.General;
|
||||||
|
|
||||||
namespace PostFundManagement.Api.Endpoints.Communications;
|
namespace PostFundManagement.Api.Endpoints.Communications;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using PostFundManagement.Api.Extensions;
|
|
||||||
using PostFundManagement.Application.Api.Filters;
|
using PostFundManagement.Application.Api.Filters;
|
||||||
using PostFundManagement.Application.Extensions;
|
using PostFundManagement.Application.Extensions;
|
||||||
using PostFundManagement.Domain.Extensions;
|
using PostFundManagement.Domain.Extensions;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using PostFundManagement.Application.Shared;
|
using PostFundManagement.Application.Shared;
|
||||||
using static PostFundManagement.Domain.Extensions.General;
|
using static PostFundManagement.Application.Extensions.General;
|
||||||
using static PostFundManagement.Domain.Extensions.Constants;
|
using static PostFundManagement.Domain.Extensions.Constants;
|
||||||
|
|
||||||
namespace PostFundManagement.Application.Api.Filters;
|
namespace PostFundManagement.Application.Api.Filters;
|
||||||
|
|||||||
@@ -7,3 +7,13 @@ public class SyncUserEvent : EventBase, IEvent
|
|||||||
{
|
{
|
||||||
public string Name { get; set; } = nameof(SyncUserEvent);
|
public string Name { get; set; } = nameof(SyncUserEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SyncUserEventHandler(ILogger<SyncUserEvent> logger) : INotificationHandler<SyncUserEvent>
|
||||||
|
{
|
||||||
|
public ValueTask Handle(SyncUserEvent notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
logger.LogInformation("Integration Sync executed. Correlation ID: {CorrelationId}", notification.CorrelationId);
|
||||||
|
|
||||||
|
return ValueTask.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
namespace PostFundManagement.Application.Communications.Events;
|
|
||||||
|
|
||||||
public class SyncUserEventHandler(ILogger<SyncUserEvent> logger) : INotificationHandler<SyncUserEvent>
|
|
||||||
{
|
|
||||||
public ValueTask Handle(SyncUserEvent notification, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
logger.LogInformation("Integration Sync executed. Correlation ID: {CorrelationId}", notification.CorrelationId);
|
|
||||||
|
|
||||||
return ValueTask.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,4 +16,33 @@ public static class General
|
|||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Guid GetUserId(this HttpContext context) => (Guid)context.Items[Domain.Extensions.Constants.UserIdItemKey]!;
|
||||||
|
|
||||||
|
public static string GetUserEmail(this HttpContext context) => (string)context.Items[Domain.Extensions.Constants.EmaiItemKey]!;
|
||||||
|
|
||||||
|
public static (bool Decoded, Guid userId) GetUserId(this ClaimsPrincipal principal)
|
||||||
|
{
|
||||||
|
var sidClaim = principal.FindFirst("sid")?.Value ?? principal.FindFirst(ClaimTypes.Sid)?.Value;
|
||||||
|
|
||||||
|
var decoded = Guid.TryParse(sidClaim, out var userId);
|
||||||
|
|
||||||
|
return (decoded, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (bool Decoded, Guid email) GetUserEmail(this ClaimsPrincipal principal)
|
||||||
|
{
|
||||||
|
var emailClaim = principal.FindFirst("email")?.Value ?? principal.FindFirst(ClaimTypes.Email)?.Value;
|
||||||
|
|
||||||
|
var decoded = Guid.TryParse(emailClaim, out var email);
|
||||||
|
|
||||||
|
return (decoded, email);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Microsoft.AspNetCore.Mvc.ProblemDetails ToProblems(this IReadOnlyList<IError> errors) => new()
|
||||||
|
{
|
||||||
|
Detail = string.Join(',', errors.Select(e => e.Message)),
|
||||||
|
Status = StatusCodes.Status400BadRequest,
|
||||||
|
Title = errors[0]?.Message,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,4 +1,10 @@
|
|||||||
namespace PostFundManagement.Domain.Extensions;
|
using OpenTelemetry.Exporter;
|
||||||
|
using OpenTelemetry.Logs;
|
||||||
|
using OpenTelemetry.Resources;
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
using OpenTelemetry.Metrics;
|
||||||
|
|
||||||
|
namespace PostFundManagement.Application.Extensions;
|
||||||
|
|
||||||
public static class Otel
|
public static class Otel
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
using PostFundManagement.Infrastructure.Database;
|
using PostFundManagement.Infrastructure.Database;
|
||||||
using static PostFundManagement.Domain.Extensions.Constants;
|
using static PostFundManagement.Domain.Extensions.Constants;
|
||||||
|
|
||||||
namespace PostFundManagement.Api.Extensions;
|
namespace PostFundManagement.Application.Extensions;
|
||||||
|
|
||||||
public static class Postgres
|
public static class Postgres
|
||||||
{
|
{
|
||||||
+1
-2
@@ -1,10 +1,9 @@
|
|||||||
using PostFundManagement.Application.Extensions;
|
|
||||||
using PostFundManagement.Application.Shared;
|
using PostFundManagement.Application.Shared;
|
||||||
using PostFundManagement.Domain.Api.Configuration;
|
using PostFundManagement.Domain.Api.Configuration;
|
||||||
using PostFundManagement.Domain.Sdk;
|
using PostFundManagement.Domain.Sdk;
|
||||||
using PostFundManagement.Infrastructure.Database;
|
using PostFundManagement.Infrastructure.Database;
|
||||||
|
|
||||||
namespace PostFundManagement.Api.Extensions;
|
namespace PostFundManagement.Application.Extensions;
|
||||||
|
|
||||||
public static class Security
|
public static class Security
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace PostFundManagement.Infrastructure.Configuration;
|
namespace PostFundManagement.Domain.Api.Configuration;
|
||||||
|
|
||||||
public sealed class MachineIdentity
|
public sealed class MachineIdentity
|
||||||
{
|
{
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
namespace PostFundManagement.Domain.Extensions;
|
|
||||||
|
|
||||||
public static class General
|
|
||||||
{
|
|
||||||
public static Guid GetUserId(this HttpContext context) => (Guid)context.Items[Constants.UserIdItemKey]!;
|
|
||||||
|
|
||||||
public static string GetUserEmail(this HttpContext context) => (string)context.Items[Constants.EmaiItemKey]!;
|
|
||||||
|
|
||||||
public static (bool Decoded, Guid userId) GetUserId(this ClaimsPrincipal principal)
|
|
||||||
{
|
|
||||||
var sidClaim = principal.FindFirst("sid")?.Value ?? principal.FindFirst(ClaimTypes.Sid)?.Value;
|
|
||||||
|
|
||||||
var decoded = Guid.TryParse(sidClaim, out var userId);
|
|
||||||
|
|
||||||
return (decoded, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static (bool Decoded, Guid email) GetUserEmail(this ClaimsPrincipal principal)
|
|
||||||
{
|
|
||||||
var emailClaim = principal.FindFirst("email")?.Value ?? principal.FindFirst(ClaimTypes.Email)?.Value;
|
|
||||||
|
|
||||||
var decoded = Guid.TryParse(emailClaim, out var email);
|
|
||||||
|
|
||||||
return (decoded, email);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Microsoft.AspNetCore.Mvc.ProblemDetails ToProblems(this IReadOnlyList<IError> errors) => new()
|
|
||||||
{
|
|
||||||
Detail = string.Join(',', errors.Select(e => e.Message)),
|
|
||||||
Status = StatusCodes.Status400BadRequest,
|
|
||||||
Title = errors[0]?.Message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user