30 lines
714 B
C#
30 lines
714 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.DTOs;
|
|
using LittleShop.Services;
|
|
|
|
namespace LittleShop.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class AuthController : ControllerBase
|
|
{
|
|
private readonly IAuthService _authService;
|
|
|
|
public AuthController(IAuthService authService)
|
|
{
|
|
_authService = authService;
|
|
}
|
|
|
|
[HttpPost("login")]
|
|
public async Task<ActionResult<AuthResponseDto>> Login([FromBody] LoginDto loginDto)
|
|
{
|
|
var result = await _authService.LoginAsync(loginDto);
|
|
|
|
if (result != null)
|
|
{
|
|
return Ok(result);
|
|
}
|
|
|
|
return Unauthorized(new { message = "Invalid credentials" });
|
|
}
|
|
} |