diff --git a/Moonlight/Core/Configuration/CoreConfiguration.cs b/Moonlight/Core/Configuration/CoreConfiguration.cs index 3e3fcfd1..9c881884 100644 --- a/Moonlight/Core/Configuration/CoreConfiguration.cs +++ b/Moonlight/Core/Configuration/CoreConfiguration.cs @@ -69,6 +69,10 @@ public class CoreConfiguration [JsonProperty("TokenDuration")] [Description("This specifies the duration the token of an user will be valid. The value specifies the days")] public int TokenDuration { get; set; } = 30; + + [JsonProperty("DenyRegister")] + [Description("This disables the register function. No user will be able to sign up anymore. Its recommended to enable this for private instances")] + public bool DenyRegister { get; set; } = false; } public class SecurityData diff --git a/Moonlight/Core/UI/Components/Auth/Register.razor b/Moonlight/Core/UI/Components/Auth/Register.razor index 91da10f7..f4899cd2 100644 --- a/Moonlight/Core/UI/Components/Auth/Register.razor +++ b/Moonlight/Core/UI/Components/Auth/Register.razor @@ -6,57 +6,70 @@ @using Moonlight.Core.Models.Forms @using Moonlight.Core.Services @using MoonCore.Exceptions +@using MoonCore.Services @using MoonCoreUI.Services +@using Moonlight.Core.Configuration @inject IAuthenticationProvider AuthenticationProvider @inject IdentityService IdentityService @inject CookieService CookieService @inject NavigationManager Navigation +@inject ConfigService ConfigService
-
-
- Register -
-
- Register in order to start managing your services -
-
- - -
- -
- -
- -
- -
- -
- -
- -
- - - -
- -
-
Or
- @* OAuth2 Providers here *@ + @if (ConfigService.Get().Authentication.DenyRegister) + { + + The administrator of this instance has disabled to sign up function
+ Back to login +
+ } + else + { +
+
+ Register +
+
+ Register in order to start managing your services
- + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + +
+ +
+
Or
+ @* OAuth2 Providers here *@ +
+
+
+ }
@@ -67,6 +80,9 @@ private async Task OnValidSubmit() { + if (ConfigService.Get().Authentication.DenyRegister) + throw new DisplayException("The sign up function has been disabled"); + if (Form.Password != Form.RepeatedPassword) throw new DisplayException("The passwords do not match");