mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Make sure BTCPayServer does not take the culture of the server
This commit is contained in:
parent
86092fc955
commit
4b30132d06
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.WebSockets;
|
||||
using System.Threading.Tasks;
|
||||
@ -32,6 +33,8 @@ namespace BTCPayServer.Hosting
|
||||
|
||||
public async Task Invoke(HttpContext httpContext)
|
||||
{
|
||||
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
var bitpayAuth = GetBitpayAuth(httpContext, out bool isBitpayAuth);
|
||||
|
@ -32,6 +32,7 @@ using Microsoft.Net.Http.Headers;
|
||||
using NBitcoin;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BTCPayServer.Controllers.GreenField;
|
||||
using System.Globalization;
|
||||
|
||||
namespace BTCPayServer.Hosting
|
||||
{
|
||||
@ -113,6 +114,7 @@ namespace BTCPayServer.Hosting
|
||||
o.Filters.Add(new XContentTypeOptionsAttribute("nosniff"));
|
||||
o.Filters.Add(new XXSSProtectionAttribute());
|
||||
o.Filters.Add(new ReferrerPolicyAttribute("same-origin"));
|
||||
o.ModelBinderProviders.Insert(0, new ModelBinders.DefaultModelBinderProvider());
|
||||
//o.Filters.Add(new ContentSecurityPolicyAttribute()
|
||||
//{
|
||||
// FontSrc = "'self' https://fonts.gstatic.com/",
|
||||
@ -121,7 +123,7 @@ namespace BTCPayServer.Hosting
|
||||
// StyleSrc = "'self' 'unsafe-inline'",
|
||||
// ScriptSrc = "'self' 'unsafe-inline'"
|
||||
//});
|
||||
})
|
||||
})
|
||||
.ConfigureApiBehaviorOptions(options =>
|
||||
{
|
||||
options.InvalidModelStateResponseFactory = context =>
|
||||
@ -142,8 +144,6 @@ namespace BTCPayServer.Hosting
|
||||
.AddPlugins(services, Configuration, LoggerFactory)
|
||||
.AddControllersAsServices();
|
||||
|
||||
|
||||
|
||||
services.TryAddScoped<ContentSecurityPolicies>();
|
||||
services.Configure<IdentityOptions>(options =>
|
||||
{
|
||||
|
29
BTCPayServer/ModelBinders/DefaultModelBinderProvider.cs
Normal file
29
BTCPayServer/ModelBinders/DefaultModelBinderProvider.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Payments;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
namespace BTCPayServer.ModelBinders
|
||||
{
|
||||
public class DefaultModelBinderProvider : IModelBinderProvider
|
||||
{
|
||||
public IModelBinder GetBinder(ModelBinderProviderContext context)
|
||||
{
|
||||
if (context.Metadata.ModelType == typeof(decimal) || context.Metadata.ModelType == typeof(decimal?))
|
||||
return new InvariantDecimalModelBinder();
|
||||
if (context.Metadata.ModelType == typeof(PaymentMethodId))
|
||||
return new PaymentMethodIdModelBinder();
|
||||
if (context.Metadata.ModelType == typeof(WalletIdModelBinder))
|
||||
return new ModelBinders.WalletIdModelBinder();
|
||||
if (typeof(DateTimeOffset).GetTypeInfo().IsAssignableFrom(context.Metadata.ModelType) ||
|
||||
typeof(DateTimeOffset?).GetTypeInfo().IsAssignableFrom(context.Metadata.ModelType))
|
||||
{
|
||||
return new DateTimeOffsetModelBinder();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user