37 lines
1003 B
C#
37 lines
1003 B
C#
using Flexitime.Objects;
|
|
using FlexitimeAPI.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FlexitimeAPI.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class AuthenticationController:ControllerBase
|
|
{
|
|
private readonly IUserService _userService;
|
|
public AuthenticationController(IUserService userService)
|
|
{
|
|
_userService = userService;
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult Authenticate(LoginRequest model)
|
|
{
|
|
var response = _userService.Authenticate(model);
|
|
|
|
if (response == null)
|
|
return BadRequest(new { message = "Username or password is incorrect" });
|
|
|
|
return Ok(response);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("logout")]
|
|
public IActionResult Logout()
|
|
{
|
|
//should be able to get the id here and log a message of that user logging out..
|
|
return Ok();
|
|
}
|
|
}
|
|
}
|