48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
using uWine.Core.Infrastructure.Services;
|
|
|
|
namespace uWine.Api.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("/[controller]")]
|
|
public class TestController : Controller
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
private readonly OwnerService _ownerService;
|
|
private readonly AuthenticationService _authenticationService;
|
|
private readonly UserService _userService;
|
|
|
|
public TestController(IConfiguration configuration,
|
|
OwnerService ownerService,
|
|
AuthenticationService authenticationService,
|
|
UserService userService)
|
|
{
|
|
_configuration = configuration;
|
|
_ownerService = ownerService;
|
|
_authenticationService = authenticationService;
|
|
_userService = userService;
|
|
}
|
|
|
|
[HttpGet("cklogin")]
|
|
public IActionResult test()
|
|
{
|
|
try
|
|
{
|
|
var TUserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
var userId = int.Parse(User.FindFirst("userId").Value);
|
|
var role = User.FindFirst(ClaimTypes.Role)?.Value;
|
|
|
|
var user = _userService.Process(userId);
|
|
|
|
return Ok(new { userId, TUserId, role, user });
|
|
}
|
|
catch
|
|
{
|
|
return Unauthorized(new { status = 401 });
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|