Browse Source
Merge pull request #12085 from abpframework/get-name-surname-from-external-login
Get user's name, surname and phone number from external login
pull/12093/head
maliming
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
26 additions and
0 deletions
-
framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Microsoft/AspNetCore/Authentication/OAuth/Claims/AbpClaimActionCollectionExtensions.cs
-
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs
|
|
|
@ -13,6 +13,20 @@ public static class AbpClaimActionCollectionExtensions |
|
|
|
claimActions.DeleteClaim("name"); |
|
|
|
claimActions.RemoveDuplicate(AbpClaimTypes.UserName); |
|
|
|
} |
|
|
|
|
|
|
|
if (AbpClaimTypes.Name != "given_name") |
|
|
|
{ |
|
|
|
claimActions.MapJsonKey(AbpClaimTypes.Name, "given_name"); |
|
|
|
claimActions.DeleteClaim("given_name"); |
|
|
|
claimActions.RemoveDuplicate(AbpClaimTypes.Name); |
|
|
|
} |
|
|
|
|
|
|
|
if (AbpClaimTypes.SurName != "family_name") |
|
|
|
{ |
|
|
|
claimActions.MapJsonKey(AbpClaimTypes.SurName, "family_name"); |
|
|
|
claimActions.DeleteClaim("family_name"); |
|
|
|
claimActions.RemoveDuplicate(AbpClaimTypes.SurName); |
|
|
|
} |
|
|
|
|
|
|
|
if (AbpClaimTypes.Email != "email") |
|
|
|
{ |
|
|
|
|
|
|
|
@ -277,6 +277,18 @@ public class LoginModel : AccountPageModel |
|
|
|
CheckIdentityErrors(await UserManager.SetEmailAsync(user, emailAddress)); |
|
|
|
CheckIdentityErrors(await UserManager.AddLoginAsync(user, info)); |
|
|
|
CheckIdentityErrors(await UserManager.AddDefaultRolesAsync(user)); |
|
|
|
|
|
|
|
user.Name = info.Principal.FindFirstValue(AbpClaimTypes.Name); |
|
|
|
user.Surname = info.Principal.FindFirstValue(AbpClaimTypes.SurName); |
|
|
|
|
|
|
|
var phoneNumber = info.Principal.FindFirstValue(AbpClaimTypes.PhoneNumber); |
|
|
|
if (!phoneNumber.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
var phoneNumberConfirmed = string.Equals(info.Principal.FindFirstValue(AbpClaimTypes.PhoneNumberVerified), "true", StringComparison.InvariantCultureIgnoreCase); |
|
|
|
user.SetPhoneNumber(phoneNumber, phoneNumberConfirmed); |
|
|
|
} |
|
|
|
|
|
|
|
await UserManager.UpdateAsync(user); |
|
|
|
|
|
|
|
return user; |
|
|
|
} |
|
|
|
|