Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[Route("api/[controller]")]
public class TokenController : Controller
{
[HttpPost]
public IActionResult Post([FromBody]LoginModel loginModel)
{
if (loginModel.Username != "stephany" && loginModel.Password != "batista")
return Unauthorized();
var token = new JwtTokenBuilder()
.AddSecurityKey(JwtSecurityKey.Create("a-password-very-big-to-be-good"))
.AddSubject("Stehany Batista")
.AddIssuer("stephanybatista.com")
.AddAudience("stephanybatista.com")
.AddNameId("salmeidabatista@gmail.com")
.AddClaim("employeer", "31")
.AddExpiry(1)
.Build();
return Ok(token);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment