Skip to content

Instantly share code, notes, and snippets.

View ep-cc's full-sized avatar
🏠
Working from home

Peter Erben ep-cc

🏠
Working from home
  • Codecool
  • Budapest
  • 05:29 (UTC +01:00)
View GitHub Profile
@ep-cc
ep-cc / AuthController.cs
Last active June 17, 2024 11:37
Dotnet core JWT auth using cookie
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] LoginRquest login)
{
try
{
var user = await _userService.AuthenticateUser(login);
var token = GenerateToken(user);
// This is the extra step
HttpContext.Response.Cookies.Append("access_token", token, new CookieOptions{HttpOnly = true});