authenticate with jwt (.netcore webapi) sample project


 using Microsoft.AspNetCore.Mvc;

using CoreApiMekanik.Models;
using CoreApiMekanik.Services;

namespace CoreApiMekanik.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class UsersController : ControllerBase
    {
        private IUserService _userService;

        public UsersController(IUserService userService)
        {
            _userService = userService;
        }

        [HttpPost("authenticate")]
        public IActionResult Authenticate(AuthenticateRequest model)
        {
            var response = _userService.Authenticate(model);

            if (response == null)
                return BadRequest(new { message = "Username or password is incorrect" });

            return Ok(response);
        }

         
    }
}





github public:

https://github.com/doktoralban/CoreApiMekanik

Yorumlar