Skip to content

Commit

Permalink
Merge pull request #1703 from haacked/comment-3f539b07
Browse files Browse the repository at this point in the history
Comment by DaN on external-claims
  • Loading branch information
haacked authored Jan 20, 2024
2 parents a8f8e84 + 1cf1a8f commit 0578f3d
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 0578f3d

Please sign in to comment.