From ac313388b5928306dae493a612d903c6ce2ce87a Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 2 Oct 2023 10:28:28 +0800 Subject: [PATCH] Allow users to edit user name. --- .../src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml | 2 +- .../Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml index 7535e2ac40..fabe41ae6f 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml @@ -12,7 +12,7 @@ @L["Login"]
- @if (Model.EnableLocalRegister) + @if ((!Model.IsExternalLogin || Model.UserNameExtracted) && Model.EnableLocalRegister) { } 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 be889a4a00..1ef7f00d55 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 @@ -36,6 +36,7 @@ public class RegisterModel : AccountPageModel [BindProperty(SupportsGet = true)] public string ExternalLoginAuthSchema { get; set; } + public bool UserNameExtracted { get; set; } public IEnumerable ExternalProviders { get; set; } public IEnumerable VisibleExternalProviders => ExternalProviders.Where(x => !string.IsNullOrWhiteSpace(x.DisplayName)); public bool EnableLocalRegister { get; set; } @@ -122,7 +123,11 @@ public class RegisterModel : AccountPageModel Logger.LogWarning("External login info is not available"); return RedirectToPage("./Login"); } - + if (Input.UserName.IsNullOrWhiteSpace()) + { + Input.UserName = await GetUserNameFromEmail(Input.EmailAddress); + } + UserNameExtracted = true; await RegisterExternalUserAsync(externalLoginInfo, Input.UserName, Input.EmailAddress); } else