From ea701f2cd6dc1444071568e409cf1df3d71e402b Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Wed, 2 Nov 2016 10:30:22 -0700 Subject: [PATCH] Added UserClaimsPrincipal to ViewComponent Addresses #4964 --- src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponent.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponent.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponent.cs index 0084aa222a..f9352d8d25 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponent.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponent.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; using System.Security.Principal; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ModelBinding; @@ -60,6 +61,11 @@ namespace Microsoft.AspNetCore.Mvc } } + /// + /// Gets the for the current user. + /// + public ClaimsPrincipal UserClaimsPrincipal => ViewContext?.HttpContext?.User; + /// /// Gets the for the current request. ///