mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Update namespace organization in service layer
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
using BusinessLayer.Services;
|
||||
using DataAccessLayer.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceCore.Services;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AuthController(IAuthService auth) : ControllerBase
|
||||
public class AuthController(IAuthService auth, IJwtService jwtService) : ControllerBase
|
||||
{
|
||||
public record RegisterRequest(
|
||||
string Username,
|
||||
@@ -39,9 +39,15 @@ namespace WebAPI.Controllers
|
||||
[HttpPost("login")]
|
||||
public async Task<ActionResult> Login([FromBody] LoginRequest req)
|
||||
{
|
||||
var ok = await auth.LoginAsync(req.UsernameOrEmail, req.Password);
|
||||
if (!ok) return Unauthorized();
|
||||
return Ok(new { success = true });
|
||||
var userAccount = await auth.LoginAsync(req.UsernameOrEmail, req.Password);
|
||||
if (userAccount is null)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
var jwt = jwtService.GenerateJwt(userAccount.UserAccountId, userAccount.Username, userAccount.DateOfBirth);
|
||||
|
||||
return Ok(new { AccessToken = jwt, Message = "Logged in successfully." });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using BusinessLayer.Services;
|
||||
using DataAccessLayer.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceCore.Services;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BusinessLayer.Services;
|
||||
using DataAccessLayer.Repositories.UserAccount;
|
||||
using DataAccessLayer.Repositories.UserCredential;
|
||||
using DataAccessLayer.Sql;
|
||||
using ServiceCore.Services;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -16,6 +16,7 @@ builder.Services.AddScoped<IUserAccountRepository, UserAccountRepository>();
|
||||
builder.Services.AddScoped<IUserService, UserService>();
|
||||
builder.Services.AddScoped<IUserCredentialRepository, UserCredentialRepository>();
|
||||
builder.Services.AddScoped<IAuthService, AuthService>();
|
||||
builder.Services.AddScoped<IJwtService, JwtService>();
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
Reference in New Issue
Block a user