using BuaaLocationServer.Middlewares.Jwts; using Microsoft.AspNetCore.Mvc; namespace BuaaLocationServer.Controllers { public class BaseController:ControllerBase { protected string GetCurrentUserName() { var sub = this.HttpContext.User.Claims.First(e => e.Properties.Any(x => x.Value == JwtClaimTypes.Subject)); return sub.Value; } } }