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.
43 lines
1.3 KiB
43 lines
1.3 KiB
using BajajAutoBooking.Api.Interface;
|
|
using BajajAutoBooking.Common.Authentication;
|
|
using iTextSharp.tool.xml.html;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Web.Http;
|
|
|
|
namespace BajajAutoBooking.WebApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Microsoft.AspNetCore.Mvc.Route("JWTAuth")]
|
|
public class JWTAuthController : ControllerBase
|
|
{
|
|
private readonly IConfiguration _config;
|
|
|
|
public JWTAuthController(IConfiguration configuration)
|
|
{
|
|
_config = configuration;
|
|
}
|
|
|
|
/// <summary>
|
|
/// GetAuthToken
|
|
/// </summary>
|
|
/// <param name="userLogin"></param>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[Microsoft.AspNetCore.Mvc.HttpPost]
|
|
[SwaggerOperation(Tags = new[] { "JWTAuth" })]
|
|
[Microsoft.AspNetCore.Mvc.Route("GetAuthToken")]
|
|
public ActionResult<string> GetAuthToken(AuthValidateModel userLogin)
|
|
{
|
|
string token = string.Empty;
|
|
AuthenticationHelper helper = new AuthenticationHelper(_config);
|
|
AuthModel userInfo = helper.Authenticate(userLogin);
|
|
if (userInfo != null)
|
|
{
|
|
token = helper.GenerateToken(userInfo);
|
|
}
|
|
return token;
|
|
}
|
|
|
|
}
|
|
}
|