Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SocialSecurityNumberClaimsPrincipalContributor in Authorization.md #8698

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

maliming
Copy link
Member

public class SocialSecurityNumberClaimsPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency
{
    public async Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
    {
        var identity = context.ClaimsPrincipal.Identities.FirstOrDefault();
        var userId = identity?.FindUserId();
        if (userId.HasValue)
        {
            var userService = context.ServiceProvider.GetRequiredService<IUserService>(); //Your custom service
            var socialSecurityNumber = await userService.GetSocialSecurityNumberAsync(userId.Value);
            if (socialSecurityNumber != null)
            {
                identity.AddOrReplace(new Claim("SocialSecurityNumber", socialSecurityNumber));
            }
        }
    }
}

@maliming maliming changed the title Update Authorization.md Update SocialSecurityNumberClaimsPrincipalContributor in Authorization.md Apr 20, 2021
@maliming maliming requested a review from hikalkan April 20, 2021 02:13
@maliming maliming added this to the 4.3-final milestone Apr 20, 2021
@hikalkan hikalkan merged commit 61e7cbc into rel-4.3 Apr 20, 2021
@hikalkan hikalkan deleted the maliming-patch-1 branch April 20, 2021 22:34
@hikalkan
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants