diff --git a/.csharpierrc.json b/.csharpierrc.json
index 0e17843..afd1cb3 100644
--- a/.csharpierrc.json
+++ b/.csharpierrc.json
@@ -1,9 +1,19 @@
{
+ "$schema": "https://json.schemastore.org/csharpier.json",
+
"printWidth": 80,
"useTabs": false,
- "tabWidth": 4,
- "endOfLine": "auto",
- "indentStyle": "space",
- "lineEndings": "auto",
- "wrapLineLength": 80
+ "indentSize": 4,
+ "endOfLine": "lf",
+
+ "overrides": [
+ {
+ "files": "*.xml",
+ "indentSize": 2
+ },
+ {
+ "files": "*.csx",
+ "printWidth": 80
+ }
+ ]
}
diff --git a/src/Core/API/API.Core/API.Core.csproj b/src/Core/API/API.Core/API.Core.csproj
index 739d159..61c6ba5 100644
--- a/src/Core/API/API.Core/API.Core.csproj
+++ b/src/Core/API/API.Core/API.Core.csproj
@@ -1,39 +1,42 @@
-
- net10.0
- enable
- enable
- API.Core
- Linux
-
+
+ net10.0
+ enable
+ enable
+ API.Core
+ Linux
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
- .dockerignore
-
-
+
+
+ .dockerignore
+
+
diff --git a/src/Core/API/API.Core/Authentication/JwtAuthenticationHandler.cs b/src/Core/API/API.Core/Authentication/JwtAuthenticationHandler.cs
index 514f0e4..cb07381 100644
--- a/src/Core/API/API.Core/Authentication/JwtAuthenticationHandler.cs
+++ b/src/Core/API/API.Core/Authentication/JwtAuthenticationHandler.cs
@@ -14,39 +14,57 @@ public class JwtAuthenticationHandler(
IConfiguration configuration
) : AuthenticationHandler(options, logger, encoder)
{
- protected override async Task HandleAuthenticateAsync()
- {
- // Get the JWT secret from configuration
- var secret = configuration["Jwt:SecretKey"]
- ?? throw new InvalidOperationException("JWT SecretKey is not configured");
+ protected override async Task HandleAuthenticateAsync()
+ {
+ // Get the JWT secret from configuration
+ var secret =
+ configuration["Jwt:SecretKey"]
+ ?? throw new InvalidOperationException(
+ "JWT SecretKey is not configured"
+ );
- // Check if Authorization header exists
- if (!Request.Headers.TryGetValue("Authorization", out var authHeaderValue))
- {
- return AuthenticateResult.Fail("Authorization header is missing");
- }
+ // Check if Authorization header exists
+ if (
+ !Request.Headers.TryGetValue(
+ "Authorization",
+ out var authHeaderValue
+ )
+ )
+ {
+ return AuthenticateResult.Fail("Authorization header is missing");
+ }
- var authHeader = authHeaderValue.ToString();
- if (!authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
- {
- return AuthenticateResult.Fail("Invalid authorization header format");
- }
+ var authHeader = authHeaderValue.ToString();
+ if (
+ !authHeader.StartsWith(
+ "Bearer ",
+ StringComparison.OrdinalIgnoreCase
+ )
+ )
+ {
+ return AuthenticateResult.Fail(
+ "Invalid authorization header format"
+ );
+ }
- var token = authHeader.Substring("Bearer ".Length).Trim();
+ var token = authHeader.Substring("Bearer ".Length).Trim();
- try
- {
- var claimsPrincipal = await tokenInfrastructure.ValidateJwtAsync(token, secret);
- var ticket = new AuthenticationTicket(claimsPrincipal, Scheme.Name);
- return AuthenticateResult.Success(ticket);
- }
- catch (Exception ex)
- {
- return AuthenticateResult.Fail($"Token validation failed: {ex.Message}");
- }
- }
+ try
+ {
+ var claimsPrincipal = await tokenInfrastructure.ValidateJwtAsync(
+ token,
+ secret
+ );
+ var ticket = new AuthenticationTicket(claimsPrincipal, Scheme.Name);
+ return AuthenticateResult.Success(ticket);
+ }
+ catch (Exception ex)
+ {
+ return AuthenticateResult.Fail(
+ $"Token validation failed: {ex.Message}"
+ );
+ }
+ }
}
-public class JwtAuthenticationOptions : AuthenticationSchemeOptions
-{
-}
+public class JwtAuthenticationOptions : AuthenticationSchemeOptions { }
diff --git a/src/Core/API/API.Core/Contracts/Auth/AuthDTO.cs b/src/Core/API/API.Core/Contracts/Auth/AuthDTO.cs
index 849f4e1..124ae2e 100644
--- a/src/Core/API/API.Core/Contracts/Auth/AuthDTO.cs
+++ b/src/Core/API/API.Core/Contracts/Auth/AuthDTO.cs
@@ -18,6 +18,4 @@ public record RegistrationPayload(
bool ConfirmationEmailSent
);
-public record ConfirmationPayload(
- Guid UserAccountId,
- DateTime ConfirmedDate);
+public record ConfirmationPayload(Guid UserAccountId, DateTime ConfirmedDate);
diff --git a/src/Core/API/API.Core/Contracts/Auth/RefreshToken.cs b/src/Core/API/API.Core/Contracts/Auth/RefreshToken.cs
index e697656..0914d52 100644
--- a/src/Core/API/API.Core/Contracts/Auth/RefreshToken.cs
+++ b/src/Core/API/API.Core/Contracts/Auth/RefreshToken.cs
@@ -4,16 +4,16 @@ namespace API.Core.Contracts.Auth;
public record RefreshTokenRequest
{
- public string RefreshToken { get; init; } = default!;
+ public string RefreshToken { get; init; } = default!;
}
public class RefreshTokenRequestValidator
: AbstractValidator
{
- public RefreshTokenRequestValidator()
- {
- RuleFor(x => x.RefreshToken)
- .NotEmpty()
- .WithMessage("Refresh token is required");
- }
+ public RefreshTokenRequestValidator()
+ {
+ RuleFor(x => x.RefreshToken)
+ .NotEmpty()
+ .WithMessage("Refresh token is required");
+ }
}
diff --git a/src/Core/API/API.Core/Controllers/AuthController.cs b/src/Core/API/API.Core/Controllers/AuthController.cs
index 0129b9a..e9ce3b4 100644
--- a/src/Core/API/API.Core/Controllers/AuthController.cs
+++ b/src/Core/API/API.Core/Controllers/AuthController.cs
@@ -87,9 +87,7 @@ namespace API.Core.Controllers
[FromBody] RefreshTokenRequest req
)
{
- var rtn = await tokenService.RefreshTokenAsync(
- req.RefreshToken
- );
+ var rtn = await tokenService.RefreshTokenAsync(req.RefreshToken);
return Ok(
new ResponseBody
diff --git a/src/Core/API/API.Core/Controllers/ProtectedController.cs b/src/Core/API/API.Core/Controllers/ProtectedController.cs
index e14d658..6b6d8b7 100644
--- a/src/Core/API/API.Core/Controllers/ProtectedController.cs
+++ b/src/Core/API/API.Core/Controllers/ProtectedController.cs
@@ -1,7 +1,7 @@
+using System.Security.Claims;
using API.Core.Contracts.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using System.Security.Claims;
namespace API.Core.Controllers;
@@ -10,22 +10,18 @@ namespace API.Core.Controllers;
[Authorize(AuthenticationSchemes = "JWT")]
public class ProtectedController : ControllerBase
{
- [HttpGet]
- public ActionResult> Get()
- {
- var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
- var username = User.FindFirst(ClaimTypes.Name)?.Value;
+ [HttpGet]
+ public ActionResult> Get()
+ {
+ var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
+ var username = User.FindFirst(ClaimTypes.Name)?.Value;
- return Ok(
- new ResponseBody