tuitio/IdentityServer.Api/Controllers/IdentityController.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2020-12-20 03:06:43 +02:00
using IdentityServer.Application.Commands;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace IdentityServer.Api.Controllers
{
[ApiController]
[Route("identity")]
public class IdentityController : ControllerBase
{
private readonly IMediator _mediator;
public IdentityController(IMediator mediator)
{
_mediator = mediator;
}
[HttpPost("authenticate/{userName}/{password}")]
public async Task<IActionResult> AuthenticateUser([FromRoute] AuthenticateUser authenticateUser)
{
var result = await _mediator.Send(authenticateUser);
if (result != null)
return Ok(result);
else
return BadRequest();
}
[HttpPost("authorize/{token}")]
public async Task<IActionResult> AuthorizeToken([FromRoute] AuthorizeToken authorizeToken)
{
var result = await _mediator.Send(authorizeToken);
if (result != null)
return Ok(result);
else
return BadRequest();
}
}
}