Skip to content

Commit

Permalink
Fix for bug Jumoo#49 to ensure only user ids set are unfrozen when ma…
Browse files Browse the repository at this point in the history
…intenance mode is active
  • Loading branch information
PaigeLigeti-SM committed Oct 17, 2024
1 parent 141b692 commit e9970f6
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 10 deletions.
15 changes: 15 additions & 0 deletions Our.Umbraco.MaintenanceMode/Models/MaintenanceModeSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;

namespace Our.Umbraco.MaintenanceMode.Models
{
Expand All @@ -13,6 +15,19 @@ public class MaintenanceModeSettings
/// users who can get past the content freeze
/// </summary>
public string UnfrozenUsers { get; set; } = "";

public List<string> UnfrozenUsersList
{
get
{
return UnfrozenUsers?.Split(',')
.Select(s => s.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.Distinct()
.ToList() ?? new List<string>();
}
}

public MaintenanceMode ViewModel { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentDeletingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentMovingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentMovingToRecycleBinNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentPublishingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentSavingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(ContentUnpublishingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(MediaDeletingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(MediaMovingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(MediaMovingToRecycleBinNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Handle(MediaSavingNotification notification)
{
if (_backofficeUserAccessor.BackofficeUser == null) return;

if (_maintenanceModeService.Status.Settings.UnfrozenUsers.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;
if (_maintenanceModeService.Status.Settings.UnfrozenUsersList.Contains(_backofficeUserAccessor.BackofficeUser.GetId().ToString())) return;


notification.CancelOperation(new EventMessage("Warning", "This site is currently frozen during updates", EventMessageType.Error));
Expand Down

0 comments on commit e9970f6

Please sign in to comment.