public class MySuperImportantService
{
private ClaimsPrincipal _user;
public MySuperImportantService(ClaimsPrincipal user)
{
this._user = user;
}
public string SuperImportantMethod()
{
//Do super important stuff
string username = _user.Identity.Name; //or _user.FindFirst("nameidentifier");
//Do stuff with username.
}
}