Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
933 B

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Microsoft.Extensions.Options;
using Squidex.Infrastructure.Translations;
namespace Squidex.Infrastructure.Commands;
public sealed class ReadonlyCommandMiddleware(IOptions<ReadonlyOptions> options) : ICommandMiddleware
{
private readonly ReadonlyOptions options = options.Value;
public Task HandleAsync(CommandContext context, NextDelegate next,
CancellationToken ct)
{
if (options.IsReadonly)
{
throw new DomainException(T.Get("common.readonlyMode"));
}
return next(context, ct);
}
}