testapi
This commit is contained in:
1 parent
2db9525570
commit
5aca82244e
21 files changed
+545
-126
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using uWine.Core.Infrastructure.Services;
|
||||
|
||||
namespace uWine.Api.Controllers
|
||||
{
|
||||
@@ -8,23 +9,37 @@ namespace uWine.Api.Controllers
|
||||
public class TestController : Controller
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly OwnerService _ownerService;
|
||||
private readonly AuthenticationService _authenticationService;
|
||||
private readonly UserService _userService;
|
||||
|
||||
public TestController(IConfiguration configuration) {
|
||||
_configuration = configuration;
|
||||
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 = User.FindFirst("userId").Value;
|
||||
var userId = int.Parse(User.FindFirst("userId").Value);
|
||||
var role = User.FindFirst(ClaimTypes.Role)?.Value;
|
||||
return Ok(new { userId, TUserId, role });
|
||||
|
||||
var user = _userService.Process(userId);
|
||||
|
||||
return Ok(new { userId, TUserId, role, user });
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Unauthorized("\"title\": \"Unauthorized\"");
|
||||
return Unauthorized(new { status = 401 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user