You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
using Biskilog_Accounting.Shared.ClientContractModels;
|
|
using Biskilog_Accounting.Shared.Interfaces;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.DotNet.Scaffolding.Shared.CodeModifier.CodeChange;
|
|
|
|
namespace Biskilog_Accounting.Server.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class AuthenticationController : ControllerBase
|
|
{
|
|
private readonly IAuthService m_authService;
|
|
private readonly ITokenService m_tokenService;
|
|
public AuthenticationController(IAuthService a_authService, ITokenService a_tokenService)
|
|
{
|
|
m_authService = a_authService;
|
|
m_tokenService = a_tokenService;
|
|
}
|
|
|
|
[HttpPost, Route("type-a")]
|
|
public async Task<IActionResult> AuthUser(Userauth a_userData)
|
|
{
|
|
|
|
if (a_userData != null && a_userData.Username != null && a_userData.Passsword != null)
|
|
{
|
|
var token = await m_authService.AuthenticateClient(a_userData.Username, a_userData.Passsword);
|
|
|
|
if (token == null)
|
|
return BadRequest("Invalid credentials");
|
|
return Ok(token.ToString());
|
|
}
|
|
else
|
|
{
|
|
return BadRequest();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|