Skip to content

Commit

Permalink
Split SMS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed Mar 31, 2024
1 parent 8281b1f commit 97e77df
Show file tree
Hide file tree
Showing 67 changed files with 911 additions and 1,058 deletions.
7 changes: 7 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Email.Smtp", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Azure", "src\OrchardCore.Modules\OrchardCore.Sms.Azure\OrchardCore.Sms.Azure.csproj", "{013C8BBF-6879-4B47-80C9-A466923E45E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Twilio", "src\OrchardCore.Modules\OrchardCore.Sms.Twilio\OrchardCore.Sms.Twilio.csproj", "{3AC5FA88-5548-45F3-A14A-B344D32898F7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1377,6 +1379,10 @@ Global
{013C8BBF-6879-4B47-80C9-A466923E45E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{013C8BBF-6879-4B47-80C9-A466923E45E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{013C8BBF-6879-4B47-80C9-A466923E45E5}.Release|Any CPU.Build.0 = Release|Any CPU
{3AC5FA88-5548-45F3-A14A-B344D32898F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AC5FA88-5548-45F3-A14A-B344D32898F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AC5FA88-5548-45F3-A14A-B344D32898F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AC5FA88-5548-45F3-A14A-B344D32898F7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1615,6 +1621,7 @@ Global
{C35AB37B-5A09-4896-BEEE-B126B7E7018A} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{E8A1097D-A65A-4B17-A3A2-F50D79552732} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{013C8BBF-6879-4B47-80C9-A466923E45E5} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{3AC5FA88-5548-45F3-A14A-B344D32898F7} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46A1D25A-78D1-4476-9CBF-25B75E296341}
Expand Down

This file was deleted.

54 changes: 0 additions & 54 deletions src/OrchardCore.Modules/OrchardCore.Sms.Azure/AdminMenu.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
using OrchardCore.Sms.Azure.Models;
using OrchardCore.Sms.Azure.Services;
using OrchardCore.Sms.Azure.ViewModels;
using OrchardCore.Sms.Services;

namespace OrchardCore.Sms.Azure.Drivers;

public class AzureSettingsDisplayDriver : SectionDisplayDriver<ISite, AzureSettings>
public class AzureSmsSettingsDisplayDriver : SectionDisplayDriver<ISite, AzureSmsSettings>
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAuthorizationService _authorizationService;
Expand All @@ -34,16 +35,16 @@ public class AzureSettingsDisplayDriver : SectionDisplayDriver<ISite, AzureSetti
protected readonly IHtmlLocalizer H;
protected readonly IStringLocalizer S;

public AzureSettingsDisplayDriver(
public AzureSmsSettingsDisplayDriver(
IHttpContextAccessor httpContextAccessor,
IAuthorizationService authorizationService,
IPhoneFormatValidator phoneFormatValidator,
IDataProtectionProvider dataProtectionProvider,
IShellHost shellHost,
ShellSettings shellSettings,
INotifier notifier,
IHtmlLocalizer<AzureSettingsDisplayDriver> htmlLocalizer,
IStringLocalizer<AzureSettingsDisplayDriver> stringLocalizer)
IHtmlLocalizer<AzureSmsSettingsDisplayDriver> htmlLocalizer,
IStringLocalizer<AzureSmsSettingsDisplayDriver> stringLocalizer)
{
_httpContextAccessor = httpContextAccessor;
_authorizationService = authorizationService;
Expand All @@ -56,24 +57,24 @@ public AzureSettingsDisplayDriver(
S = stringLocalizer;
}

public override IDisplayResult Edit(AzureSettings settings)
public override IDisplayResult Edit(AzureSmsSettings settings)
{
return Initialize<AzureSettingsViewModel>("TwilioSettings_Edit", model =>
return Initialize<AzureSettingsViewModel>("AzureSmsSettings_Edit", model =>
{
model.IsEnabled = settings.IsEnabled;
model.ConnectionString = settings.ConnectionString;
model.PhoneNumber = settings.PhoneNumber;
}).Location("Content:5#Twilio")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, SmsPermissions.ManageSmsSettings))
}).Location("Content:5#Azure")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageSmsSettings))
.OnGroup(SmsSettings.GroupId);
}

public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureSettings settings, IUpdateModel updater, BuildEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureSmsSettings settings, IUpdateModel updater, BuildEditorContext context)
{
var user = _httpContextAccessor.HttpContext?.User;

if (!context.GroupId.Equals(SmsSettings.GroupId, StringComparison.OrdinalIgnoreCase)
|| !await _authorizationService.AuthorizeAsync(user, SmsPermissions.ManageSmsSettings))
|| !await _authorizationService.AuthorizeAsync(user, Permissions.ManageSmsSettings))
{
return null;
}
Expand Down Expand Up @@ -121,7 +122,16 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureSettings
hasChanges |= settings.ConnectionString != model.ConnectionString;
hasChanges |= settings.PhoneNumber != model.PhoneNumber;

settings.ConnectionString = model.ConnectionString;
if (!string.IsNullOrWhiteSpace(model.ConnectionString))
{
var protector = _dataProtectionProvider.CreateProtector(TwilioSmsProvider.ProtectorName);

var protectedConnectionString = protector.Protect(model.ConnectionString);
hasChanges |= settings.ConnectionString != protectedConnectionString;

settings.ConnectionString = protectedConnectionString;
}

settings.PhoneNumber = model.PhoneNumber;
}

Expand Down
Loading

0 comments on commit 97e77df

Please sign in to comment.