diff --git a/LctMonolith/Application/Middleware/ErrorHandlingMiddleware.cs b/LctMonolith/Application/Middleware/ErrorHandlingMiddleware.cs
index b26789c..2cad718 100644
--- a/LctMonolith/Application/Middleware/ErrorHandlingMiddleware.cs
+++ b/LctMonolith/Application/Middleware/ErrorHandlingMiddleware.cs
@@ -4,13 +4,14 @@ using Serilog;
namespace LctMonolith.Application.Middleware;
-///
-/// Global error handling middleware capturing unhandled exceptions and converting to standardized JSON response.
-///
public class ErrorHandlingMiddleware
{
private readonly RequestDelegate _next;
- public ErrorHandlingMiddleware(RequestDelegate next) => _next = next;
+
+ public ErrorHandlingMiddleware(RequestDelegate next)
+ {
+ _next = next;
+ }
public async Task Invoke(HttpContext ctx)
{
@@ -20,17 +21,18 @@ public class ErrorHandlingMiddleware
}
catch (OperationCanceledException)
{
- // Client aborted request (non-standard 499 code used by some proxies)
if (!ctx.Response.HasStarted)
{
- ctx.Response.StatusCode = 499; // Client Closed Request (custom)
+ ctx.Response.StatusCode = 499;
}
}
catch (Exception ex)
{
Log.Error(ex, "Unhandled exception");
- if (ctx.Response.HasStarted) throw;
-
+ if (ctx.Response.HasStarted)
+ {
+ throw;
+ }
ctx.Response.ContentType = "application/json";
ctx.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
var payload = new { error = new { message = ex.Message, traceId = ctx.TraceIdentifier } };
@@ -41,6 +43,8 @@ public class ErrorHandlingMiddleware
public static class ErrorHandlingMiddlewareExtensions
{
- /// Adds global error handling middleware.
- public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder app) => app.UseMiddleware();
+ public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder app)
+ {
+ return app.UseMiddleware();
+ }
}
diff --git a/LctMonolith/Application/Options/JwtOptions.cs b/LctMonolith/Application/Options/JwtOptions.cs
index 1d2a544..e571d83 100644
--- a/LctMonolith/Application/Options/JwtOptions.cs
+++ b/LctMonolith/Application/Options/JwtOptions.cs
@@ -1,8 +1,5 @@
namespace LctMonolith.Application.Options;
-///
-/// JWT issuing configuration loaded from appsettings (section Jwt).
-///
public class JwtOptions
{
public string Key { get; set; } = string.Empty;
@@ -11,4 +8,3 @@ public class JwtOptions
public int AccessTokenMinutes { get; set; } = 60;
public int RefreshTokenDays { get; set; } = 7;
}
-
diff --git a/LctMonolith/Controllers/AnalyticsController.cs b/LctMonolith/Controllers/AnalyticsController.cs
index fc978a3..2c6cbc9 100644
--- a/LctMonolith/Controllers/AnalyticsController.cs
+++ b/LctMonolith/Controllers/AnalyticsController.cs
@@ -4,21 +4,18 @@ using Microsoft.AspNetCore.Mvc;
namespace LctMonolith.Controllers;
-///
-/// Basic analytics endpoints.
-///
[ApiController]
[Route("api/analytics")]
[Authorize]
public class AnalyticsController : ControllerBase
{
private readonly IAnalyticsService _analytics;
+
public AnalyticsController(IAnalyticsService analytics)
{
_analytics = analytics;
}
- /// Get aggregate system summary metrics.
[HttpGet("summary")]
public async Task GetSummary(CancellationToken ct)
{
@@ -26,4 +23,3 @@ public class AnalyticsController : ControllerBase
return Ok(summary);
}
}
-
diff --git a/LctMonolith/Controllers/AuthController.cs b/LctMonolith/Controllers/AuthController.cs
index e6be810..8cf0ba4 100644
--- a/LctMonolith/Controllers/AuthController.cs
+++ b/LctMonolith/Controllers/AuthController.cs
@@ -11,11 +11,8 @@ using RefreshRequest = LctMonolith.Services.Models.RefreshRequest;
namespace LctMonolith.Controllers;
-///
-/// Authentication endpoints (mocked local identity + JWT issuing).
-///
[ApiController]
-[Route("api/auth")]
+[Route("api/auth")]
public class AuthController : ControllerBase
{
private readonly UserManager _userManager;
@@ -29,34 +26,43 @@ public class AuthController : ControllerBase
_tokenService = tokenService;
}
- /// Registers a new user (simplified).
[HttpPost("register")]
[AllowAnonymous]
public async Task> Register(AuthRequest req, CancellationToken ct)
{
var existing = await _userManager.FindByEmailAsync(req.Email);
- if (existing != null) return Conflict("Email already registered");
+ if (existing != null)
+ {
+ return Conflict("Email already registered");
+ }
var user = new AppUser { UserName = req.Email, Email = req.Email, FirstName = req.FirstName, LastName = req.LastName };
var result = await _userManager.CreateAsync(user, req.Password);
- if (!result.Succeeded) return BadRequest(result.Errors);
+ if (!result.Succeeded)
+ {
+ return BadRequest(result.Errors);
+ }
var tokens = await _tokenService.IssueAsync(user, ct);
return Ok(tokens);
}
- /// Login with email + password.
[HttpPost("login")]
[AllowAnonymous]
public async Task> Login(AuthRequest req, CancellationToken ct)
{
var user = await _userManager.FindByEmailAsync(req.Email);
- if (user == null) return Unauthorized();
- var passOk = await _signInManager.CheckPasswordSignInAsync(user, req.Password, lockoutOnFailure: false);
- if (!passOk.Succeeded) return Unauthorized();
+ if (user == null)
+ {
+ return Unauthorized();
+ }
+ var passOk = await _signInManager.CheckPasswordSignInAsync(user, req.Password, false);
+ if (!passOk.Succeeded)
+ {
+ return Unauthorized();
+ }
var tokens = await _tokenService.IssueAsync(user, ct);
return Ok(tokens);
}
- /// Refresh access token by refresh token.
[HttpPost("refresh")]
[AllowAnonymous]
public async Task> Refresh(RefreshRequest req, CancellationToken ct)
@@ -65,7 +71,6 @@ public class AuthController : ControllerBase
return Ok(pair);
}
- /// Revoke refresh token (logout).
[HttpPost("revoke")]
[Authorize]
public async Task Revoke(RevokeRequest req, CancellationToken ct)
@@ -74,13 +79,11 @@ public class AuthController : ControllerBase
return NoContent();
}
- /// Returns current user id (debug).
[HttpGet("me")]
[Authorize]
public ActionResult