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;
}
2020-12-20 12:33:16 +02:00
[HttpPost("authenticate")]
public async Task<IActionResult> AuthenticateUser([FromQuery] AuthenticateUser authenticateUser)
2020-12-20 03:06:43 +02:00
{
var result = await _mediator.Send(authenticateUser);
if (result != null)
return Ok(result);
else
return BadRequest();
}
2020-12-20 12:33:16 +02:00
[HttpPost("authorize")]
public async Task<IActionResult> AuthorizeToken([FromQuery] AuthorizeToken authorizeToken)
2020-12-20 03:06:43 +02:00
{
var result = await _mediator.Send(authorizeToken);
if (result != null)
return Ok(result);
else
return BadRequest();
}
}
}