diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/SmsSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/SmsSettingsDisplayDriver.cs index 939540bc5c1..d1a24157eb5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/SmsSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/SmsSettingsDisplayDriver.cs @@ -17,8 +17,6 @@ namespace OrchardCore.Sms.Drivers; public class SmsSettingsDisplayDriver : SectionDisplayDriver { - public const string GroupId = "sms"; - private readonly IHttpContextAccessor _httpContextAccessor; private readonly IAuthorizationService _authorizationService; private readonly IShellHost _shellHost; @@ -55,14 +53,14 @@ public override async Task EditAsync(SmsSettings settings, Build .Select(provider => new SelectListItem(provider, provider)) .ToArray(); }).Location("Content:1") - .OnGroup(GroupId); + .OnGroup(SmsConstants.SettingsGroupId); } public override async Task UpdateAsync(SmsSettings settings, BuildEditorContext context) { var user = _httpContextAccessor.HttpContext?.User; - if (!context.GroupId.Equals(GroupId, StringComparison.OrdinalIgnoreCase) + if (!context.GroupId.Equals(SmsConstants.SettingsGroupId, StringComparison.OrdinalIgnoreCase) || !await _authorizationService.AuthorizeAsync(user, SmsPermissions.ManageSmsSettings)) { return null; diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/TwilioSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/TwilioSettingsDisplayDriver.cs index 78f785d41e1..7ccb7cf1ad5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/TwilioSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/Drivers/TwilioSettingsDisplayDriver.cs @@ -52,14 +52,14 @@ public override async Task EditAsync(TwilioSettings settings, Bu model.AccountSID = settings.AccountSID; model.HasAuthToken = !String.IsNullOrEmpty(settings.AuthToken); }).Location("Content:5") - .OnGroup(SmsSettingsDisplayDriver.GroupId); + .OnGroup(SmsConstants.SettingsGroupId); } public override async Task UpdateAsync(TwilioSettings settings, BuildEditorContext context) { var user = _httpContextAccessor.HttpContext?.User; - if (!context.GroupId.Equals(SmsSettingsDisplayDriver.GroupId, StringComparison.OrdinalIgnoreCase) + if (!context.GroupId.Equals(SmsConstants.SettingsGroupId, StringComparison.OrdinalIgnoreCase) || !await _authorizationService.AuthorizeAsync(user, SmsPermissions.ManageSmsSettings)) { return null; diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Sms/SmsAdminMenu.cs similarity index 83% rename from src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs rename to src/OrchardCore.Modules/OrchardCore.Sms/SmsAdminMenu.cs index 5e047d260d9..93dca151e9c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/SmsAdminMenu.cs @@ -3,15 +3,14 @@ using Microsoft.Extensions.Localization; using OrchardCore.Navigation; using OrchardCore.Sms; -using OrchardCore.Sms.Drivers; namespace OrchardCore.Admin; -public class AdminMenu : INavigationProvider +public class SmsAdminMenu : INavigationProvider { protected readonly IStringLocalizer S; - public AdminMenu(IStringLocalizer stringLocalizer) + public SmsAdminMenu(IStringLocalizer stringLocalizer) { S = stringLocalizer; } @@ -29,7 +28,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Add(S["SMS"], S["SMS"].PrefixPosition(), sms => sms .AddClass("sms") .Id("sms") - .Action("Index", "Admin", new { area = "OrchardCore.Settings", groupId = SmsSettingsDisplayDriver.GroupId }) + .Action("Index", "Admin", new { area = "OrchardCore.Settings", groupId = SmsConstants.SettingsGroupId }) .Permission(SmsPermissions.ManageSmsSettings) .LocalNav() ) diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs index bcb111398ad..e984279ef66 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/Startup.cs @@ -39,7 +39,7 @@ public override void ConfigureServices(IServiceCollection services) } services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddScoped, SmsSettingsDisplayDriver>(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/Views/SmsSettings.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Sms/Views/SmsSettings.Edit.cshtml index f398b26f225..25371e1e5a6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/Views/SmsSettings.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Sms/Views/SmsSettings.Edit.cshtml @@ -10,7 +10,7 @@ - diff --git a/src/OrchardCore/OrchardCore.Sms.Core/SmsConstants.cs b/src/OrchardCore/OrchardCore.Sms.Core/SmsConstants.cs index 15d38c8d99d..20f9cb29168 100644 --- a/src/OrchardCore/OrchardCore.Sms.Core/SmsConstants.cs +++ b/src/OrchardCore/OrchardCore.Sms.Core/SmsConstants.cs @@ -5,4 +5,6 @@ public class SmsConstants public const string TwilioServiceName = "Twilio"; public const string ConsoleServiceName = "Console"; + + public const string SettingsGroupId = "sms"; }