Refactor authentication services and implement JWT validation logic

This commit is contained in:
Aaron Po
2026-02-26 23:44:52 -05:00
parent 0ab2eaaec9
commit 250e5f2c9c
7 changed files with 106 additions and 24 deletions

View File

@@ -11,8 +11,8 @@ namespace API.Core.Controllers
public class AuthController(
IRegisterService registerService,
ILoginService loginService,
IConfirmationService confirmationService)
: ControllerBase
IConfirmationService confirmationService
) : ControllerBase
{
[HttpPost("register")]
public async Task<ActionResult<UserAccount>> Register(
@@ -69,13 +69,16 @@ namespace API.Core.Controllers
public async Task<ActionResult> Confirm([FromQuery] string token)
{
var rtn = await confirmationService.ConfirmUserAsync(token);
return Ok(new ResponseBody<ConfirmationPayload>
{
Message = "User with ID " + rtn.userId + " is confirmed.",
Payload = new ConfirmationPayload(
rtn.userId, rtn.confirmedAt
)
});
return Ok(
new ResponseBody<ConfirmationPayload>
{
Message = "User with ID " + rtn.userId + " is confirmed.",
Payload = new ConfirmationPayload(
rtn.userId,
rtn.confirmedAt
),
}
);
}
}
}
}

View File

@@ -14,8 +14,8 @@ using Infrastructure.Repository.UserAccount;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Service.Auth;
using Service.UserManagement.User;
using Service.Emails;
using Service.UserManagement.User;
var builder = WebApplication.CreateBuilder(args);