Browse Source

Update Authorization.md

pull/8698/head
maliming 6 years ago
committed by GitHub
parent
commit
43af3278a3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      docs/en/Authorization.md

15
docs/en/Authorization.md

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

Loading…
Cancel
Save