From 50058a5073fe476c8e20867907eaa552c5300422 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Fri, 10 Dec 2010 12:21:01 -0800 Subject: [PATCH 1/2] #17026: Adding web.config to /content/ directory when scafolding a theme. --HG-- branch : dev --- .../Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs index b0c561845..c19253228 100644 --- a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs @@ -292,6 +292,8 @@ namespace Orchard.CodeGeneration.Commands { createdFiles.Add(themePath + "Scripts\\Web.config"); File.WriteAllText(themePath + "Styles\\Web.config", File.ReadAllText(_codeGenTemplatePath + "StaticFilesWebConfig.txt")); createdFiles.Add(themePath + "Styles\\Web.config"); + File.WriteAllText(themePath + "Content\\Web.config", File.ReadAllText(_codeGenTemplatePath + "StaticFilesWebConfig.txt")); + createdFiles.Add(themePath + "Content\\Web.config"); var templateText = File.ReadAllText(_codeGenTemplatePath + "\\ThemeManifest.txt").Replace("$$ThemeName$$", themeName); if (string.IsNullOrEmpty(baseTheme)) { From 9a91c4d741c4cf9ecae35e843062aecbcc9ca386 Mon Sep 17 00:00:00 2001 From: Dave Reed Date: Fri, 10 Dec 2010 12:55:06 -0800 Subject: [PATCH 2/2] #16825: Exception in background task. Return null for authenticated user if there is none set and there's no HttpContext. Somehow the correct owner is already being assigned, so the previously created OwnedScheduledTaskHandler was unnecessary. --HG-- branch : dev --- .../Scheduling/OwnedScheduledTaskHandler.cs | 30 ------------------- src/Orchard.Web/Core/Orchard.Core.csproj | 1 - .../Handlers/UnpublishingTaskHandler.cs | 8 ++--- .../Handlers/PublishingTaskHandler.cs | 8 ++--- .../Providers/FormsAuthenticationService.cs | 2 +- 5 files changed, 7 insertions(+), 42 deletions(-) delete mode 100644 src/Orchard.Web/Core/Common/Scheduling/OwnedScheduledTaskHandler.cs diff --git a/src/Orchard.Web/Core/Common/Scheduling/OwnedScheduledTaskHandler.cs b/src/Orchard.Web/Core/Common/Scheduling/OwnedScheduledTaskHandler.cs deleted file mode 100644 index 5577ac963..000000000 --- a/src/Orchard.Web/Core/Common/Scheduling/OwnedScheduledTaskHandler.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Orchard.ContentManagement; -using Orchard.Core.Common.Models; -using Orchard.Security; -using Orchard.Tasks.Scheduling; - -namespace Orchard.Core.Common.Scheduling { - public abstract class OwnedScheduledTaskHandler : IScheduledTaskHandler { - private readonly IOrchardServices _orchardServices; - - protected OwnedScheduledTaskHandler(IOrchardServices orchardServices) { - _orchardServices = orchardServices; - } - - protected void SetCurrentUser(ContentItem contentItem) { - IUser owner = null; - var commonPart = contentItem.As(); - if (commonPart != null) { - owner = commonPart.Owner; - } - if (owner == null) { - var superUser = _orchardServices.WorkContext.CurrentSite.SuperUser; - owner = _orchardServices.WorkContext.Resolve().GetUser(superUser); - } - _orchardServices.WorkContext.Resolve().SetAuthenticatedUserForRequest(owner); - } - - public abstract void Process(ScheduledTaskContext context); - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 0c9308d99..67b970439 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -228,7 +228,6 @@ - diff --git a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Handlers/UnpublishingTaskHandler.cs b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Handlers/UnpublishingTaskHandler.cs index 28e955f6d..c00ead6a1 100644 --- a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Handlers/UnpublishingTaskHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Handlers/UnpublishingTaskHandler.cs @@ -1,29 +1,27 @@ using JetBrains.Annotations; using Orchard.ContentManagement; -using Orchard.Core.Common.Scheduling; using Orchard.Logging; using Orchard.Tasks.Scheduling; namespace Orchard.ArchiveLater.Handlers { [UsedImplicitly] - public class UnpublishingTaskHandler : OwnedScheduledTaskHandler { + public class UnpublishingTaskHandler : IScheduledTaskHandler { private readonly IContentManager _contentManager; - public UnpublishingTaskHandler(IContentManager contentManager, IOrchardServices orchardServices) : base(orchardServices) { + public UnpublishingTaskHandler(IContentManager contentManager, IOrchardServices orchardServices) { _contentManager = contentManager; Logger = NullLogger.Instance; } public ILogger Logger { get; set; } - public override void Process(ScheduledTaskContext context) { + public void Process(ScheduledTaskContext context) { if (context.Task.TaskType == "Unpublish") { Logger.Information("Unpublishing item #{0} version {1} scheduled at {2} utc", context.Task.ContentItem.Id, context.Task.ContentItem.Version, context.Task.ScheduledUtc); - SetCurrentUser(context.Task.ContentItem); _contentManager.Unpublish(context.Task.ContentItem); } } diff --git a/src/Orchard.Web/Modules/Orchard.PublishLater/Handlers/PublishingTaskHandler.cs b/src/Orchard.Web/Modules/Orchard.PublishLater/Handlers/PublishingTaskHandler.cs index 80ed2b1ef..abf14ea21 100644 --- a/src/Orchard.Web/Modules/Orchard.PublishLater/Handlers/PublishingTaskHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.PublishLater/Handlers/PublishingTaskHandler.cs @@ -1,29 +1,27 @@ using JetBrains.Annotations; using Orchard.ContentManagement; -using Orchard.Core.Common.Scheduling; using Orchard.Logging; using Orchard.Tasks.Scheduling; namespace Orchard.PublishLater.Handlers { [UsedImplicitly] - public class PublishingTaskHandler : OwnedScheduledTaskHandler { + public class PublishingTaskHandler : IScheduledTaskHandler { private readonly IContentManager _contentManager; - public PublishingTaskHandler(IContentManager contentManager, IOrchardServices orchardServices) : base(orchardServices) { + public PublishingTaskHandler(IContentManager contentManager, IOrchardServices orchardServices) { _contentManager = contentManager; Logger = NullLogger.Instance; } public ILogger Logger { get; set; } - public override void Process(ScheduledTaskContext context) { + public void Process(ScheduledTaskContext context) { if (context.Task.TaskType == "Publish") { Logger.Information("Publishing item #{0} version {1} scheduled at {2} utc", context.Task.ContentItem.Id, context.Task.ContentItem.Version, context.Task.ScheduledUtc); - SetCurrentUser(context.Task.ContentItem); _contentManager.Publish(context.Task.ContentItem); } } diff --git a/src/Orchard/Security/Providers/FormsAuthenticationService.cs b/src/Orchard/Security/Providers/FormsAuthenticationService.cs index 3f2b2cf6c..27c09c994 100644 --- a/src/Orchard/Security/Providers/FormsAuthenticationService.cs +++ b/src/Orchard/Security/Providers/FormsAuthenticationService.cs @@ -70,7 +70,7 @@ namespace Orchard.Security.Providers { return _signedInUser; var httpContext = _httpContextAccessor.Current(); - if (!httpContext.Request.IsAuthenticated || !(httpContext.User.Identity is FormsIdentity)) { + if (httpContext == null || !httpContext.Request.IsAuthenticated || !(httpContext.User.Identity is FormsIdentity)) { return null; }