From 779dd26527907a59d246c95fb1f30d0c386f43b7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 16 Sep 2015 15:22:40 +0200 Subject: [PATCH] Fixes: U4-6969 Property label localization in 7.3 always uses en-US locale --- .../BackOfficeCookieAuthenticationProvider.cs | 28 +++++++++++++++++++ src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../Security/Identity/AppBuilderExtensions.cs | 4 +-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs diff --git a/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs b/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs new file mode 100644 index 0000000000..5247ea0af4 --- /dev/null +++ b/src/Umbraco.Core/Security/BackOfficeCookieAuthenticationProvider.cs @@ -0,0 +1,28 @@ +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Owin.Security.Cookies; + +namespace Umbraco.Core.Security +{ + public class BackOfficeCookieAuthenticationProvider : CookieAuthenticationProvider + { + /// + /// Ensures that the culture is set correctly for the current back office user + /// + /// + /// + public override Task ValidateIdentity(CookieValidateIdentityContext context) + { + var umbIdentity = context.Identity as UmbracoBackOfficeIdentity; + if (umbIdentity != null && umbIdentity.IsAuthenticated) + { + Thread.CurrentThread.CurrentCulture = + Thread.CurrentThread.CurrentUICulture = + new CultureInfo(umbIdentity.Culture); + } + + return base.ValidateIdentity(context); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 2ea422c3a6..4552cac7f5 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -459,6 +459,7 @@ + diff --git a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs index 11bdf48897..317ae7f729 100644 --- a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs +++ b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs @@ -134,7 +134,7 @@ namespace Umbraco.Web.Security.Identity GlobalSettings.TimeOutInMinutes, GlobalSettings.UseSSL) { - Provider = new CookieAuthenticationProvider + Provider = new BackOfficeCookieAuthenticationProvider { // Enables the application to validate the security stamp when the user // logs in. This is a security feature which is used when you @@ -143,7 +143,7 @@ namespace Umbraco.Web.Security.Identity .OnValidateIdentity( TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager), - identity => identity.GetUserId()) + identity => identity.GetUserId()), } };