From dc893bc40cc977fceffc4cee5d0354a0eea0e40e Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 16 Oct 2023 16:36:45 +0800 Subject: [PATCH] Try to get `email` from `AbpClaimTypes.Email` and `ClaimTypes.Email`. --- .../src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs | 4 ++-- .../src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index 187d1b9f4f..ab5e2819cb 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -229,7 +229,7 @@ public class LoginModel : AccountPageModel //TODO: Handle other cases for result! - var email = loginInfo.Principal.FindFirstValue(AbpClaimTypes.Email); + var email = loginInfo.Principal.FindFirstValue(AbpClaimTypes.Email) ?? loginInfo.Principal.FindFirstValue(ClaimTypes.Email); if (email.IsNullOrWhiteSpace()) { return RedirectToPage("./Register", new { @@ -268,7 +268,7 @@ public class LoginModel : AccountPageModel { await IdentityOptions.SetAsync(); - var emailAddress = info.Principal.FindFirstValue(AbpClaimTypes.Email); + var emailAddress = info.Principal.FindFirstValue(AbpClaimTypes.Email) ?? info.Principal.FindFirstValue(ClaimTypes.Email); var userName = await GetUserNameFromEmail(emailAddress); var user = new IdentityUser(GuidGenerator.Create(), userName, emailAddress, CurrentTenant.Id); diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index 1ef7f00d55..722eca26b7 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Options; using Volo.Abp.Account.Settings; using Volo.Abp.Auditing; using Volo.Abp.Identity; +using Volo.Abp.Security.Claims; using Volo.Abp.Settings; using Volo.Abp.Validation; using IdentityUser = Volo.Abp.Identity.IdentityUser; @@ -92,7 +93,7 @@ public class RegisterModel : AccountPageModel } var identity = externalLoginInfo.Principal.Identities.First(); - var emailClaim = identity.FindFirst(ClaimTypes.Email); + var emailClaim = identity.FindFirst(AbpClaimTypes.Email) ?? identity.FindFirst(ClaimTypes.Email); if (emailClaim == null) {