Add option to disable registration

This commit is contained in:
jvyden 2021-11-25 00:39:44 -05:00
commit 9b73a94b65
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 10 additions and 2 deletions

View file

@ -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
{

View file

@ -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<IActionResult> 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)

View file

@ -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;
}
}