Added the option to disable register
This commit is contained in:
@@ -69,6 +69,10 @@ public class CoreConfiguration
|
|||||||
[JsonProperty("TokenDuration")]
|
[JsonProperty("TokenDuration")]
|
||||||
[Description("This specifies the duration the token of an user will be valid. The value specifies the days")]
|
[Description("This specifies the duration the token of an user will be valid. The value specifies the days")]
|
||||||
public int TokenDuration { get; set; } = 30;
|
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
|
public class SecurityData
|
||||||
|
|||||||
@@ -6,16 +6,28 @@
|
|||||||
@using Moonlight.Core.Models.Forms
|
@using Moonlight.Core.Models.Forms
|
||||||
@using Moonlight.Core.Services
|
@using Moonlight.Core.Services
|
||||||
@using MoonCore.Exceptions
|
@using MoonCore.Exceptions
|
||||||
|
@using MoonCore.Services
|
||||||
@using MoonCoreUI.Services
|
@using MoonCoreUI.Services
|
||||||
|
@using Moonlight.Core.Configuration
|
||||||
|
|
||||||
@inject IAuthenticationProvider AuthenticationProvider
|
@inject IAuthenticationProvider AuthenticationProvider
|
||||||
@inject IdentityService IdentityService
|
@inject IdentityService IdentityService
|
||||||
@inject CookieService CookieService
|
@inject CookieService CookieService
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
|
@inject ConfigService<CoreConfiguration> ConfigService
|
||||||
|
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<div class="card card-body m-15 p-15">
|
<div class="card card-body m-15 p-15">
|
||||||
|
@if (ConfigService.Get().Authentication.DenyRegister)
|
||||||
|
{
|
||||||
|
<IconAlert Color="danger" Icon="bx-shield-quarter" Title="Sign up disabled">
|
||||||
|
The administrator of this instance has disabled to sign up function<br />
|
||||||
|
Back to <a href="/login">login</a>
|
||||||
|
</IconAlert>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
<div class="text-center mb-8">
|
<div class="text-center mb-8">
|
||||||
<div class="fw-bold mb-3 fs-1">
|
<div class="fw-bold mb-3 fs-1">
|
||||||
Register
|
Register
|
||||||
@@ -57,6 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SmartForm>
|
</SmartForm>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,6 +80,9 @@
|
|||||||
|
|
||||||
private async Task OnValidSubmit()
|
private async Task OnValidSubmit()
|
||||||
{
|
{
|
||||||
|
if (ConfigService.Get().Authentication.DenyRegister)
|
||||||
|
throw new DisplayException("The sign up function has been disabled");
|
||||||
|
|
||||||
if (Form.Password != Form.RepeatedPassword)
|
if (Form.Password != Form.RepeatedPassword)
|
||||||
throw new DisplayException("The passwords do not match");
|
throw new DisplayException("The passwords do not match");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user