55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
|
|
using DomainResults.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using WeatherForecast.Models.Requests;
|
|
using WeatherForecast.Services;
|
|
|
|
namespace WeatherForecast.Controllers;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class AuthenticationController : ControllerBase {
|
|
|
|
private readonly IAuthenticationService _authenticationService;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="authenticationService"></param>
|
|
public AuthenticationController(
|
|
IAuthenticationService authenticationService
|
|
) {
|
|
_authenticationService = authenticationService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// By providing username and password user obtains jwt token
|
|
/// </summary>
|
|
/// <param name="requestData"></param>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpPost()]
|
|
public IActionResult Post([FromBody] AuthenticationRequestModel requestData) {
|
|
var result = _authenticationService.Post(requestData);
|
|
return result.ToActionResult();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Authorize(Policy = "WhitelistToken")]
|
|
[HttpGet()]
|
|
|
|
public IActionResult Get() {
|
|
return Ok();
|
|
}
|
|
}
|
|
|