In progress
Some checks failed
Code Coverage / Generate Coverage Report (push) Has been cancelled
Tests / Run Tests (9.0.x) (push) Has been cancelled
Tests / Docker Build Test (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled

This commit is contained in:
Yaojia Wang
2025-11-03 14:00:24 +01:00
parent fe8ad1c1f9
commit 1f66b25f30
74 changed files with 9609 additions and 28 deletions

View File

@@ -0,0 +1,38 @@
using ColaFlow.Modules.Identity.Application.Commands.Login;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace ColaFlow.API.Controllers;
[ApiController]
[Route("api/[controller]")]
public class AuthController : ControllerBase
{
private readonly IMediator _mediator;
public AuthController(IMediator mediator)
{
_mediator = mediator;
}
/// <summary>
/// Login with email and password
/// </summary>
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] LoginCommand command)
{
var result = await _mediator.Send(command);
return Ok(result);
}
/// <summary>
/// Get current user (requires authentication)
/// </summary>
[HttpGet("me")]
// [Authorize] // TODO: Add after JWT middleware is configured
public async Task<IActionResult> GetCurrentUser()
{
// TODO: Implement after JWT middleware
return Ok(new { message = "Current user endpoint - to be implemented" });
}
}

View File

@@ -0,0 +1,55 @@
using ColaFlow.Modules.Identity.Application.Commands.RegisterTenant;
using ColaFlow.Modules.Identity.Application.Queries.GetTenantBySlug;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace ColaFlow.API.Controllers;
[ApiController]
[Route("api/[controller]")]
public class TenantsController : ControllerBase
{
private readonly IMediator _mediator;
public TenantsController(IMediator mediator)
{
_mediator = mediator;
}
/// <summary>
/// Register a new tenant (company signup)
/// </summary>
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] RegisterTenantCommand command)
{
var result = await _mediator.Send(command);
return Ok(result);
}
/// <summary>
/// Get tenant by slug (for login page tenant resolution)
/// </summary>
[HttpGet("{slug}")]
public async Task<IActionResult> GetBySlug(string slug)
{
var query = new GetTenantBySlugQuery(slug);
var result = await _mediator.Send(query);
if (result == null)
return NotFound(new { message = "Tenant not found" });
return Ok(result);
}
/// <summary>
/// Check if tenant slug is available
/// </summary>
[HttpGet("check-slug/{slug}")]
public async Task<IActionResult> CheckSlug(string slug)
{
var query = new GetTenantBySlugQuery(slug);
var result = await _mediator.Send(query);
return Ok(new { available = result == null });
}
}