main
|
Last change
on this file since 73b69b2 was e294f7d, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago |
|
Added JWT authentication
|
-
Property mode
set to
100644
|
|
File size:
923 bytes
|
| Rev | Line | |
|---|
| [e294f7d] | 1 | using ChapterX.Application.Auth;
|
|---|
| 2 | using MediatR;
|
|---|
| 3 | using Microsoft.AspNetCore.Authorization;
|
|---|
| 4 | using Microsoft.AspNetCore.Mvc;
|
|---|
| 5 |
|
|---|
| 6 | namespace ChapterX.API.Controllers
|
|---|
| 7 | {
|
|---|
| 8 | [Route("api/[controller]")]
|
|---|
| 9 | [ApiController]
|
|---|
| 10 | public class AuthController : ControllerBase
|
|---|
| 11 | {
|
|---|
| 12 | private readonly IMediator _mediator;
|
|---|
| 13 |
|
|---|
| 14 | public AuthController(IMediator mediator)
|
|---|
| 15 | {
|
|---|
| 16 | _mediator = mediator;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | [HttpPost("register")]
|
|---|
| 20 | [AllowAnonymous]
|
|---|
| 21 | public async Task<ActionResult> Register([FromBody] RegisterRequest request)
|
|---|
| 22 | {
|
|---|
| 23 | var response = await _mediator.Send(request);
|
|---|
| 24 | return Ok(response);
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | [HttpPost("login")]
|
|---|
| 28 | [AllowAnonymous]
|
|---|
| 29 | public async Task<ActionResult> Login([FromBody] LoginRequest request)
|
|---|
| 30 | {
|
|---|
| 31 | var response = await _mediator.Send(request);
|
|---|
| 32 | return Ok(response);
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.