Browse Source
Merge pull request #8698 from abpframework/maliming-patch-1
Update SocialSecurityNumberClaimsPrincipalContributor in Authorization.md
pull/8711/head
Halil İbrahim Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
9 deletions
-
docs/en/Authorization.md
|
|
|
@ -405,17 +405,14 @@ public class SocialSecurityNumberClaimsPrincipalContributor : IAbpClaimsPrincipa |
|
|
|
public async Task ContributeAsync(AbpClaimsPrincipalContributorContext context) |
|
|
|
{ |
|
|
|
var identity = context.ClaimsPrincipal.Identities.FirstOrDefault(); |
|
|
|
if (identity != null) |
|
|
|
var userId = identity?.FindUserId(); |
|
|
|
if (userId.HasValue) |
|
|
|
{ |
|
|
|
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>(); |
|
|
|
if (currentUser.Id.HasValue) |
|
|
|
var userService = context.ServiceProvider.GetRequiredService<IUserService>(); //Your custom service |
|
|
|
var socialSecurityNumber = await userService.GetSocialSecurityNumberAsync(userId.Value); |
|
|
|
if (socialSecurityNumber != null) |
|
|
|
{ |
|
|
|
var userService = context.ServiceProvider.GetRequiredService<IUserService>(); //Your custom service |
|
|
|
var socialSecurityNumber = await userService.GetSocialSecurityNumberAsync(currentUser.Id.Value); |
|
|
|
if (userService != null) |
|
|
|
{ |
|
|
|
identity.AddOrReplace(new Claim("SocialSecurityNumber", userService)); |
|
|
|
} |
|
|
|
identity.AddOrReplace(new Claim("SocialSecurityNumber", socialSecurityNumber)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|