Skip to content

Commit

Permalink
Comment by DaN on external-claims
Browse files Browse the repository at this point in the history
  • Loading branch information
DaN committed Jan 19, 2024
1 parent a8f8e84 commit 1cf1a8f
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions _data/comments/external-claims/3f539b07.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
id: 3f539b07
date: 2024-01-19T23:26:21.8691734Z
name: DaN
avatar: https://secure.gravatar.com/avatar/2523ef835f2b054a1d6291bf5f66e688?s=80&d=identicon&r=pg
message: >+
I have implemented IUserClaimsPrincipalFactory and it seems that there is no need to inject SignInManager.
public async override Task<ClaimsPrincipal> CreateAsync(User user)
{
var principal = await base.CreateAsync(user);
if (principal.Identity is ClaimsIdentity claimsIdentity)
{
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext != null)
{
var auth = await httpContext.AuthenticateAsync(IdentityConstants.ExternalScheme);
var authClaims = auth.Principal?.Claims;
if (authClaims != null)
{
claimsIdentity.AddClaims(authClaims);
}
}
}
return principal;
}

0 comments on commit 1cf1a8f

Please sign in to comment.