Browse Source

Allow users to edit user name.

pull/17755/head
maliming 3 years ago
parent
commit
ac313388b5
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml
  2. 7
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml

@ -12,7 +12,7 @@
<a href="@Url.Page("./Login", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Login"]</a> <a href="@Url.Page("./Login", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Login"]</a>
</strong> </strong>
<form method="post" class="mt-4"> <form method="post" class="mt-4">
@if (Model.EnableLocalRegister) @if ((!Model.IsExternalLogin || Model.UserNameExtracted) && Model.EnableLocalRegister)
{ {
<abp-input asp-for="Input.UserName" auto-focus="true"/> <abp-input asp-for="Input.UserName" auto-focus="true"/>
} }

7
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs

@ -36,6 +36,7 @@ public class RegisterModel : AccountPageModel
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string ExternalLoginAuthSchema { get; set; } public string ExternalLoginAuthSchema { get; set; }
public bool UserNameExtracted { get; set; }
public IEnumerable<ExternalProviderModel> ExternalProviders { get; set; } public IEnumerable<ExternalProviderModel> ExternalProviders { get; set; }
public IEnumerable<ExternalProviderModel> VisibleExternalProviders => ExternalProviders.Where(x => !string.IsNullOrWhiteSpace(x.DisplayName)); public IEnumerable<ExternalProviderModel> VisibleExternalProviders => ExternalProviders.Where(x => !string.IsNullOrWhiteSpace(x.DisplayName));
public bool EnableLocalRegister { get; set; } public bool EnableLocalRegister { get; set; }
@ -122,7 +123,11 @@ public class RegisterModel : AccountPageModel
Logger.LogWarning("External login info is not available"); Logger.LogWarning("External login info is not available");
return RedirectToPage("./Login"); return RedirectToPage("./Login");
} }
if (Input.UserName.IsNullOrWhiteSpace())
{
Input.UserName = await GetUserNameFromEmail(Input.EmailAddress);
}
UserNameExtracted = true;
await RegisterExternalUserAsync(externalLoginInfo, Input.UserName, Input.EmailAddress); await RegisterExternalUserAsync(externalLoginInfo, Input.UserName, Input.EmailAddress);
} }
else else

Loading…
Cancel
Save