[Fixes #6494] SSL missing settings banner showing on frontend (#7302)

Fixes #6494
This commit is contained in:
Matthew Harris 2016-10-13 20:16:33 +01:00 committed by Sébastien Ros
parent 99b0fd6ca7
commit 8a80daa9b7
3 changed files with 33 additions and 6 deletions

View File

@ -3,7 +3,6 @@ using System.Web.Mvc;
using Orchard.Localization;
using Orchard.Mvc.Filters;
using Orchard.SecureSocketsLayer.Services;
using Orchard.UI.Notify;
namespace Orchard.SecureSocketsLayer.Filters {
public class SecureSocketsLayersFilter : FilterProvider, IActionFilter {
@ -17,11 +16,6 @@ namespace Orchard.SecureSocketsLayer.Filters {
public Localizer T { get; set; }
public void OnActionExecuted(ActionExecutedContext filterContext) {
var settings = _sslService.GetSettings();
if (!settings.Enabled) {
_orchardServices.Notifier.Warning(T("You need to configure the SSL settings."));
}
}
public void OnActionExecuting(ActionExecutingContext filterContext) {

View File

@ -116,6 +116,7 @@
<Compile Include="Filters\SecureSocketsLayersFilter.cs" />
<Compile Include="Handlers\SslSettingsPartHandler.cs" />
<Compile Include="Models\SslSettingsPart.cs" />
<Compile Include="Services\MissingSettingsBanner.cs" />
<Compile Include="Services\SecureSocketsLayerSettingsProvider.cs" />
<Compile Include="Services\ISecureSocketsLayerService.cs" />
<Compile Include="Services\SecureSocketsLayerService.cs" />

View File

@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.UI.Admin.Notification;
using Orchard.UI.Notify;
namespace Orchard.SecureSocketsLayer.Services {
public class MissingSettingsBanner : INotificationProvider {
private readonly IOrchardServices _orchardServices;
private readonly ISecureSocketsLayerService _sslService;
public MissingSettingsBanner(IOrchardServices orchardServices, ISecureSocketsLayerService sslService) {
_orchardServices = orchardServices;
_sslService = sslService;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public IEnumerable<NotifyEntry> GetNotifications() {
var workContext = _orchardServices.WorkContext;
var settings = _sslService.GetSettings();
if (!settings.Enabled) {
var urlHelper = new UrlHelper(workContext.HttpContext.Request.RequestContext);
var url = urlHelper.Action("Ssl", "Admin", new {Area = "Settings"});
yield return new NotifyEntry {Message = T("The <a href=\"{0}\">SSL settings</a> need to be configured.", url), Type = NotifyType.Warning};
}
}
}
}