using System.Linq; using System.Security.Claims; using System.Threading; using iiie.Authentication.DBO; using Newtonsoft.Json; namespace iiie.Authentication.Business { public static class UserStorage { public static BasicUserDbo BasicUserDbo { get { var claim = ((ClaimsIdentity)Thread.CurrentPrincipal.Identity).Claims.FirstOrDefault(x => x != null && x.Type == "__userdbo__"); if (claim == null) return null; return JsonConvert.DeserializeObject(claim.Value); } set { var claim = new Claim("__userdbo__", JsonConvert.SerializeObject(value)); ((ClaimsIdentity)Thread.CurrentPrincipal.Identity).AddClaim(claim); } } } }