api e token con ck in db
This commit is contained in:
1 parent
a172f05269
commit
2db9525570
18 files changed
+570
-161
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace uWine.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("/[controller]")]
|
||||
public class TestController : Controller
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public TestController(IConfiguration configuration) {
|
||||
_configuration = configuration;
|
||||
}
|
||||
[HttpGet("cklogin")]
|
||||
public IActionResult test()
|
||||
{
|
||||
try
|
||||
{
|
||||
var TUserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
var userId = User.FindFirst("userId").Value;
|
||||
var role = User.FindFirst(ClaimTypes.Role)?.Value;
|
||||
return Ok(new { userId, TUserId, role });
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Unauthorized("\"title\": \"Unauthorized\"");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user