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 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(); } } } }