public static TUser Extract <TUser>(this IIdentity identity) where TUser : IEntity { return(HttpContextCache.GetOrAdd("Olive.IPrincipal.ExtractedUser", () => { var id = identity?.Name; if (id == null) { return default(TUser); } return Task.Factory.RunSync(() => Database.Instance.GetOrDefault <TUser>(id)); })); }
public static TUser Extract <TUser>(this ClaimsPrincipal @this) where TUser : IEntity { return(HttpContextCache.GetOrAdd("Olive.Principal.ExtractedUser", () => { var id = @this.GetId(); if (id.IsEmpty()) { return default(TUser); } return Task.Factory.RunSync(() => Context.Current.Database().GetOrDefault <TUser>(id)); })); }