diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 2a5c4b56..9bac25d4 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -7,7 +7,10 @@ if (Model!.User == null) { Model.NavigationItemsRight.Add(new PageNavigationItem("Log in", "/login", "user alternate")); - Model.NavigationItemsRight.Add(new PageNavigationItem("Register", "/register", "user alternate edit")); + if (ServerSettings.Instance.RegistrationEnabled) + { + Model.NavigationItemsRight.Add(new PageNavigationItem("Register", "/register", "user alternate edit")); + } } else { diff --git a/ProjectLighthouse/Pages/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/RegisterForm.cshtml.cs index 5e5347ca..91a22719 100644 --- a/ProjectLighthouse/Pages/RegisterForm.cshtml.cs +++ b/ProjectLighthouse/Pages/RegisterForm.cshtml.cs @@ -4,6 +4,7 @@ using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types; +using LBPUnion.ProjectLighthouse.Types.Settings; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -20,6 +21,8 @@ namespace LBPUnion.ProjectLighthouse.Pages [SuppressMessage("ReSharper", "SpecifyStringComparison")] public async Task OnGet([FromQuery] string username, [FromQuery] string password, [FromQuery] string confirmPassword) { + if (!ServerSettings.Instance.RegistrationEnabled) return this.NotFound(); + this.WasRegisterRequest = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(confirmPassword); if (this.WasRegisterRequest) diff --git a/ProjectLighthouse/Types/Settings/ServerSettings.cs b/ProjectLighthouse/Types/Settings/ServerSettings.cs index 2826fc78..017539b3 100644 --- a/ProjectLighthouse/Types/Settings/ServerSettings.cs +++ b/ProjectLighthouse/Types/Settings/ServerSettings.cs @@ -63,7 +63,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings } } - public const int CurrentConfigVersion = 8; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE! + public const int CurrentConfigVersion = 9; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE! #region Meta @@ -93,5 +93,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings public bool UseExternalAuth { get; set; } public bool CheckForUnsafeFiles { get; set; } = true; + + public bool RegistrationEnabled { get; set; } = true; } } \ No newline at end of file