This commit is contained in:
Sébastien André
2021-04-17 22:18:18 +02:00
parent 143127cd01
commit 9f58e2b31a

View File

@@ -1,13 +1,7 @@
using System; using Microsoft.AspNetCore.Authentication.JwtBearer;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.Domain;
namespace skydiveLogs_api.Controllers namespace skydiveLogs_api.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
@@ -15,21 +9,21 @@ namespace skydiveLogs_api.Controllers
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class Base : ControllerBase public class Base : ControllerBase
{ {
public User ConnectedUser //public User ConnectedUser
{ //{
get // get
{ // {
if (_connectedUser == null) // if (_connectedUser == null)
{ // {
_connectedUser = new User(); // _connectedUser = new User();
_connectedUser.Login = User.Claims.Single(c => c.Type == ClaimTypes.Name).Value; // _connectedUser.Login = User.Claims.Single(c => c.Type == ClaimTypes.Name).Value;
_connectedUser.Id = Convert.ToInt32(User.Claims.Single(c => c.Type == ClaimTypes.UserData).Value); // _connectedUser.Id = Convert.ToInt32(User.Claims.Single(c => c.Type == ClaimTypes.UserData).Value);
} // }
return _connectedUser; // return _connectedUser;
} // }
} //}
private User _connectedUser; //private User _connectedUser;
} }
} }