Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (32 sloc) 920 Bytes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ASPNetCoreJWTSample.Dtos;
using ASPNetCoreJWTSample.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
namespace ASPNetCoreJWTSample.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class AccountController : ControllerBase
{
private readonly AccountService _accountService;
public AccountController(AccountService accountService)
{
_accountService = accountService;
}
[HttpPost]
public IActionResult Login(LoginDto loginDto)
{
var jwtToken = _accountService.Login(loginDto);
if (jwtToken == null)
{
return Unauthorized();
}
return Ok(jwtToken);
}
}
}
You can’t perform that action at this time.