Merge branch 'Sec_14_Seguridad_ASP.NET/64_Creacion_Controllers' into dev
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using CleanArchitecture.Application.Contracts.Identity;
|
||||
using CleanArchitecture.Application.Models.Identity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CleanArchitecture.API.Controllers
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
[ApiController]
|
||||
public class AccountController : ControllerBase
|
||||
{
|
||||
private readonly IAuthService authService;
|
||||
|
||||
public AccountController(IAuthService _authService)
|
||||
{
|
||||
authService = _authService;
|
||||
}
|
||||
|
||||
[HttpPost("login")]
|
||||
public async Task<ActionResult<AuthResponse>> Login([FromBody] AuthRequest request)
|
||||
{
|
||||
var response = await authService.Login(request);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpPost("register")]
|
||||
public async Task<ActionResult<RegistrationResponse>> Register([FromBody] RegistrationRequest request)
|
||||
{
|
||||
var response = await authService.Register(request);
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using CleanArchitecture.Application.Features.Streamers.Commands.DeleteStreamer;
|
||||
using CleanArchitecture.Application.Features.Streamers.Commands.UpdateStreamer;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
@@ -19,14 +20,16 @@ namespace CleanArchitecture.API.Controllers
|
||||
}
|
||||
|
||||
[HttpPost(Name = "CreateStreamer")]
|
||||
[Authorize(Roles = "Administrator")]
|
||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||
public async Task<ActionResult<int>> CreateStreamer([FromBody] CreateStreamerCommand command)
|
||||
{
|
||||
var response = await mediator.Send(command);
|
||||
return Ok(response);
|
||||
return Ok(new { StreamerId = response });
|
||||
}
|
||||
|
||||
[HttpPut(Name = "UpdateStreamer")]
|
||||
[Authorize(Roles = "Administrator")]
|
||||
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
[ProducesDefaultResponseType]
|
||||
@@ -37,6 +40,7 @@ namespace CleanArchitecture.API.Controllers
|
||||
}
|
||||
|
||||
[HttpDelete("{id}", Name = "DeleteStreamer")]
|
||||
[Authorize(Roles = "Administrator")]
|
||||
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
[ProducesDefaultResponseType]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using CleanArchitecture.Application.Features.Videos.Queries.GetVideosList;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
@@ -18,6 +19,7 @@ namespace CleanArchitecture.API.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("{username}", Name = "GetVideo")]
|
||||
[Authorize]
|
||||
[ProducesResponseType(typeof(IEnumerable<VideosVm>), (int)HttpStatusCode.OK)]
|
||||
public async Task<ActionResult<IEnumerable<VideosVm>>> GetVideosByUserName(string username)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user