mirror of
https://github.com/Wessel/nhl-setgame.git
synced 2026-07-26 02:01:45 +02:00
22 lines
579 B
C#
22 lines
579 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Backend.Interfaces;
|
|
|
|
namespace Backend.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/v1/[controller]")]
|
|
public class AuthController(IAuthService authService) : ControllerBase {
|
|
private readonly IAuthService _authService = authService;
|
|
|
|
[HttpPost("login")]
|
|
public IActionResult Login([FromBody] UserLogin credentials) {
|
|
var user = _authService.ValidateUser(credentials);
|
|
|
|
if (user != null) {
|
|
var token = _authService.GenerateJwtToken(user.Id.ToString());
|
|
return Ok(new { token });
|
|
}
|
|
|
|
return Unauthorized();
|
|
}
|
|
} |