File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace MADE . Web . Identity
2+ {
3+ using System . Security . Claims ;
4+ using Microsoft . AspNetCore . Http ;
5+
6+ /// <summary>
7+ /// Defines an accessor for retrieving the authenticated user from a <see cref="IHttpContextAccessor"/>.
8+ /// </summary>
9+ public class AuthenticatedUserAccessor : IAuthenticatedUserAccessor
10+ {
11+ private readonly IHttpContextAccessor httpContextAccessor ;
12+
13+ /// <summary>
14+ /// Initializes a new instance of the <see cref="AuthenticatedUserAccessor"/> class with an instance of the <see cref="IHttpContextAccessor"/>.
15+ /// </summary>
16+ /// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/>.</param>
17+ public AuthenticatedUserAccessor ( IHttpContextAccessor httpContextAccessor )
18+ {
19+ this . httpContextAccessor = httpContextAccessor ;
20+ }
21+
22+ /// <summary>
23+ /// Gets the authenticated user's claims principal.
24+ /// </summary>
25+ public ClaimsPrincipal ClaimsPrincipal => this . httpContextAccessor . HttpContext . User ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ namespace MADE . Web . Identity
2+ {
3+ using System . Security . Claims ;
4+
5+ /// <summary>
6+ /// Defines an interface for accessing an authenticated user's claims principal.
7+ /// </summary>
8+ public interface IAuthenticatedUserAccessor
9+ {
10+ /// <summary>
11+ /// Gets the authenticated user's claims principal.
12+ /// </summary>
13+ ClaimsPrincipal ClaimsPrincipal { get ; }
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments