@@ -40,9 +40,22 @@
private string _confirm = string.Empty;
private string _email = string.Empty;
private string _displayName = string.Empty;
+ private string _css = string.Empty;
+ private const string displayNone = "d-none";
+
+
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;
+ protected override void OnInitialized()
+ {
+ if (!PageState.Site.AllowRegistration)
+ {
+ _message = "Registration is Disabled";
+ _css = displayNone;
+ }
+ }
+
private async Task Register()
{
try
diff --git a/Oqtane.Client/Services/NotificationService.cs b/Oqtane.Client/Services/NotificationService.cs
index 6239ca8a..46b813b6 100644
--- a/Oqtane.Client/Services/NotificationService.cs
+++ b/Oqtane.Client/Services/NotificationService.cs
@@ -28,7 +28,7 @@ namespace Oqtane.Services
public async Task> GetNotificationsAsync(int siteId, string direction, int userId)
{
- var notifications = await _http.GetJsonAsync>($"{Apiurl}? siteid={siteId.ToString()}&direction={direction.ToLower()}&userid={userId.ToString()}");
+ var notifications = await _http.GetJsonAsync>($"{Apiurl}?siteid={siteId.ToString()}&direction={direction.ToLower()}&userid={userId.ToString()}");
return notifications.OrderByDescending(item => item.CreatedOn).ToList();
}
diff --git a/Oqtane.Client/Services/UserService.cs b/Oqtane.Client/Services/UserService.cs
index d81077ff..d16142b3 100644
--- a/Oqtane.Client/Services/UserService.cs
+++ b/Oqtane.Client/Services/UserService.cs
@@ -11,12 +11,14 @@ namespace Oqtane.Services
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
+ private readonly ISiteService _siteService;
- public UserService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
+ public UserService(HttpClient http, SiteState siteState, NavigationManager navigationManager, ISiteService siteService)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
+ _siteService = siteService;
}
private string Apiurl
@@ -36,6 +38,13 @@ namespace Oqtane.Services
public async Task AddUserAsync(User user)
{
+ Site site = await _siteService.GetSiteAsync(_siteState.Alias.SiteId, _siteState.Alias);
+
+ if (!site.AllowRegistration)
+ {
+ return null;
+ }
+
try
{
return await _http.PostJsonAsync(Apiurl, user);
diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs
index 77768609..a5dfe59b 100644
--- a/Oqtane.Server/Startup.cs
+++ b/Oqtane.Server/Startup.cs
@@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -41,7 +42,12 @@ namespace Oqtane
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
- services.AddMvc().AddNewtonsoftJson();
+ services.AddMvc(opt =>
+ {
+ // remove formatter that turns nulls into 204 - No Content responses
+ // sends JSON null instead
+ opt.OutputFormatters.RemoveType();
+ }).AddNewtonsoftJson();
services.AddServerSideBlazor();
// setup HttpClient for server side in a client side compatible fashion ( with auth cookie )