From 677f68b08d519ae579bb9ad428b80ac5d5082e54 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Fri, 17 Jan 2025 11:14:35 -0500 Subject: [PATCH] allow entry of name during installation --- Oqtane.Client/Installer/Installer.razor | 11 +++++++++-- Oqtane.Client/Resources/Installer/Installer.resx | 6 ++++++ Oqtane.Client/Services/InstallationService.cs | 4 ++-- .../Services/Interfaces/IInstallationService.cs | 3 ++- .../Controllers/InstallationController.cs | 14 +++++++------- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Oqtane.Client/Installer/Installer.razor b/Oqtane.Client/Installer/Installer.razor index c0187971..d5bb7dfc 100644 --- a/Oqtane.Client/Installer/Installer.razor +++ b/Oqtane.Client/Installer/Installer.razor @@ -98,6 +98,12 @@ +
+ +
+ +
+
@@ -153,6 +159,7 @@ private string _toggleConfirmPassword = string.Empty; private string _confirmPassword = string.Empty; private string _hostEmail = string.Empty; + private string _hostName = string.Empty; private List _templates; private string _template = Constants.DefaultSiteTemplate; private bool _register = true; @@ -236,7 +243,7 @@ } } - if (connectionString != "" && !string.IsNullOrEmpty(_hostUsername) && !string.IsNullOrEmpty(_hostPassword) && _hostPassword == _confirmPassword && !string.IsNullOrEmpty(_hostEmail) && _hostEmail.Contains("@")) + if (connectionString != "" && !string.IsNullOrEmpty(_hostUsername) && !string.IsNullOrEmpty(_hostPassword) && _hostPassword == _confirmPassword && !string.IsNullOrEmpty(_hostEmail) && _hostEmail.Contains("@") && !string.IsNullOrEmpty(_hostName)) { var result = await UserService.ValidateUserAsync(_hostUsername, _hostEmail, _hostPassword); if (result.Succeeded) @@ -256,7 +263,7 @@ HostUsername = _hostUsername, HostPassword = _hostPassword, HostEmail = _hostEmail, - HostName = _hostUsername, + HostName = _hostName, TenantName = TenantNames.Master, IsNewTenant = true, SiteName = Constants.DefaultSite, diff --git a/Oqtane.Client/Resources/Installer/Installer.resx b/Oqtane.Client/Resources/Installer/Installer.resx index a06752d9..cd1c2e6e 100644 --- a/Oqtane.Client/Resources/Installer/Installer.resx +++ b/Oqtane.Client/Resources/Installer/Installer.resx @@ -186,4 +186,10 @@ The Username Provided Does Not Meet The System Requirement, It Can Only Contains Letters Or Digits. + + Full Name: + + + Provide the full name of the host user + \ No newline at end of file diff --git a/Oqtane.Client/Services/InstallationService.cs b/Oqtane.Client/Services/InstallationService.cs index a9e4d3d6..e7fdce81 100644 --- a/Oqtane.Client/Services/InstallationService.cs +++ b/Oqtane.Client/Services/InstallationService.cs @@ -57,9 +57,9 @@ namespace Oqtane.Services await PostAsync($"{ApiUrl}/restart"); } - public async Task RegisterAsync(string email) + public async Task RegisterAsync(string email, string name) { - await PostJsonAsync($"{ApiUrl}/register?email={WebUtility.UrlEncode(email)}", true); + await PostJsonAsync($"{ApiUrl}/register?email={WebUtility.UrlEncode(email)}&name={WebUtility.UrlEncode(name)}", true); } } } diff --git a/Oqtane.Client/Services/Interfaces/IInstallationService.cs b/Oqtane.Client/Services/Interfaces/IInstallationService.cs index 84790c63..8f5853c8 100644 --- a/Oqtane.Client/Services/Interfaces/IInstallationService.cs +++ b/Oqtane.Client/Services/Interfaces/IInstallationService.cs @@ -39,8 +39,9 @@ namespace Oqtane.Services /// Registers a new /// /// Email of the user to be registered + /// Name of the user to be registered /// - Task RegisterAsync(string email); + Task RegisterAsync(string email, string name); } } diff --git a/Oqtane.Server/Controllers/InstallationController.cs b/Oqtane.Server/Controllers/InstallationController.cs index 92e5b289..48ddd513 100644 --- a/Oqtane.Server/Controllers/InstallationController.cs +++ b/Oqtane.Server/Controllers/InstallationController.cs @@ -60,9 +60,9 @@ namespace Oqtane.Controllers { installation = _databaseManager.Install(config); - if (installation.Success && config.Register) + if (installation.Success) { - await RegisterContact(config.HostEmail); + await RegisterContact(config.HostEmail, config.HostName); } } else @@ -257,7 +257,7 @@ namespace Oqtane.Controllers } } - private async Task RegisterContact(string email) + private async Task RegisterContact(string email, string name) { try { @@ -268,7 +268,7 @@ namespace Oqtane.Controllers { client.DefaultRequestHeaders.Add("Referer", HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value); client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.PackageId, Constants.Version)); - var response = await client.GetAsync(new Uri(url + $"/api/registry/contact/?id={_configManager.GetInstallationId()}&email={WebUtility.UrlEncode(email)}")).ConfigureAwait(false); + var response = await client.GetAsync(new Uri(url + $"/api/registry/contact/?id={_configManager.GetInstallationId()}&email={WebUtility.UrlEncode(email)}&name={WebUtility.UrlEncode(name)}")).ConfigureAwait(false); } } } @@ -278,12 +278,12 @@ namespace Oqtane.Controllers } } - // GET api//register?email=x + // GET api//register?email=x&name=y [HttpPost("register")] [Authorize(Roles = RoleNames.Host)] - public async Task Register(string email) + public async Task Register(string email, string name) { - await RegisterContact(email); + await RegisterContact(email, name); } public struct ClientAssembly