littleshop/LittleShop/Controllers/AuthController.cs
SysAdmin 553088390e Remove BTCPay completely, integrate SilverPAY only, configure TeleBot with real token
- Removed all BTCPay references from services and configuration
- Implemented SilverPAY as sole payment provider (no fallback)
- Fixed JWT authentication with proper key length (256+ bits)
- Added UsersController with full CRUD operations
- Updated User model with Email and Role properties
- Configured TeleBot with real Telegram bot token
- Fixed launchSettings.json with JWT environment variable
- E2E tests passing for authentication, catalog, orders
- Payment creation pending SilverPAY server fix

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 19:22:29 +01:00

44 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using LittleShop.DTOs;
using LittleShop.Services;
namespace LittleShop.Controllers;
[ApiController]
[Route("api/[controller]")]
public class AuthController : ControllerBase
{
private readonly IAuthService _authService;
private readonly ILogger<AuthController> _logger;
public AuthController(IAuthService authService, ILogger<AuthController> logger)
{
_authService = authService;
_logger = logger;
}
[HttpPost("login")]
public async Task<ActionResult<AuthResponseDto>> Login([FromBody] LoginDto loginDto)
{
try
{
_logger.LogInformation("Login attempt for user: {Username}", loginDto.Username);
var result = await _authService.LoginAsync(loginDto);
if (result != null)
{
_logger.LogInformation("Login successful for user: {Username}", loginDto.Username);
return Ok(result);
}
_logger.LogWarning("Login failed for user: {Username}", loginDto.Username);
return Unauthorized(new { message = "Invalid credentials" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during login for user: {Username}", loginDto.Username);
return StatusCode(500, new { message = "An error occurred during login", error = ex.Message });
}
}
}