Skip to content

Commit

Permalink
Merge branch 'main' into ma/migrations-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored May 2, 2024
2 parents 3851dc6 + c6b867e commit 264c301
Show file tree
Hide file tree
Showing 52 changed files with 487 additions and 386 deletions.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ validation:
# Add files here that are intentionally not in the navigation and thus omitted_files shouldn't warn about them.
not_in_nav: |
samples/
releases/1.9.0.md
releases/2.0.0.md
# Extensions
markdown_extensions:
Expand Down
2 changes: 1 addition & 1 deletion src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<PackageManagement Include="ncrontab" Version="3.3.3" />
<PackageManagement Include="NEST" Version="7.17.5" />
<PackageManagement Include="NJsonSchema" Version="11.0.0" />
<PackageManagement Include="NLog.Web.AspNetCore" Version="5.3.8" />
<PackageManagement Include="NLog.Web.AspNetCore" Version="5.3.10" />
<PackageManagement Include="NodaTime" Version="3.1.11" />
<PackageManagement Include="OpenIddict.Core" Version="5.4.0" />
<PackageManagement Include="OpenIddict.Server.AspNetCore" Version="5.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/OrchardCore.Build/OrchardCore.Commons.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<LangVersion>12.0</LangVersion>
<VersionPrefix>1.9.0</VersionPrefix>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>preview</VersionSuffix>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<WarningsNotAsErrors>612,618</WarningsNotAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override async Task UpdatedAsync(UpdateContentContext context)

// Search for this part.
var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(context.ContentItem.ContentType);
if (!contentTypeDefinition.Parts.Any(ctd => ctd.Name == nameof(AliasPart)))
if (contentTypeDefinition?.Parts is not null && !contentTypeDefinition.Parts.Any(ctd => string.Equals(ctd.Name, nameof(AliasPart), StringComparison.Ordinal)))
{
context.ContentItem.Remove<AliasPart>();
_partRemoved.Add(context.ContentItem.ContentItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LocalizationPartViewModel : ShapeViewModel
public string Culture { get; set; }

[BindNever]
public CultureInfo CultureInfo { get { return new CultureInfo(Culture); } }
public CultureInfo CultureInfo => CultureInfo.GetCultureInfo(Culture);

[BindNever]
public LocalizationPart LocalizationPart { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,26 @@ namespace OrchardCore.Azure.Email.Drivers;

public class AzureEmailSettingsDisplayDriver : SectionDisplayDriver<ISite, AzureEmailSettings>
{
private readonly IShellReleaseManager _shellReleaseManager;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly IEmailAddressValidator _emailValidator;

protected IStringLocalizer S;

public AzureEmailSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IHttpContextAccessor httpContextAccessor,
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IShellHost shellHost,
ShellSettings shellSettings,
IEmailAddressValidator emailValidator,
IStringLocalizer<AzureEmailSettingsDisplayDriver> stringLocalizer)
{
_shellReleaseManager = shellReleaseManager;
_httpContextAccessor = httpContextAccessor;
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_shellHost = shellHost;
_shellSettings = shellSettings;
_emailValidator = emailValidator;
S = stringLocalizer;
}
Expand Down Expand Up @@ -150,8 +147,7 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureEmailSet

if (hasChanges)
{
// Release the tenant to apply the settings when something changed.
await _shellHost.ReleaseShellContextAsync(_shellSettings);
_shellReleaseManager.RequestRelease();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public class SmtpSettingsDisplayDriver : SectionDisplayDriver<ISite, SmtpSetting
[Obsolete("This property should no longer be used. Instead use EmailSettings.GroupId")]
public const string GroupId = EmailSettings.GroupId;

private readonly IShellReleaseManager _shellReleaseManager;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly SmtpOptions _smtpOptions;
private readonly IAuthorizationService _authorizationService;
Expand All @@ -36,18 +35,16 @@ public class SmtpSettingsDisplayDriver : SectionDisplayDriver<ISite, SmtpSetting
protected readonly IStringLocalizer S;

public SmtpSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IDataProtectionProvider dataProtectionProvider,
IShellHost shellHost,
ShellSettings shellSettings,
IHttpContextAccessor httpContextAccessor,
IOptions<SmtpOptions> options,
IAuthorizationService authorizationService,
IEmailAddressValidator emailAddressValidator,
IStringLocalizer<SmtpSettingsDisplayDriver> stringLocalizer)
{
_shellReleaseManager = shellReleaseManager;
_dataProtectionProvider = dataProtectionProvider;
_shellHost = shellHost;
_shellSettings = shellSettings;
_httpContextAccessor = httpContextAccessor;
_smtpOptions = options.Value;
_authorizationService = authorizationService;
Expand Down Expand Up @@ -200,8 +197,7 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, SmtpSettings

if (hasChanges)
{
// Release the tenant to apply the settings when something changed.
await _shellHost.ReleaseShellContextAsync(_shellSettings);
_shellReleaseManager.RequestRelease();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,28 @@ public class EmailSettingsDisplayDriver : SectionDisplayDriver<ISite, EmailSetti
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAuthorizationService _authorizationService;
private readonly IShellHost _shellHost;
private readonly EmailOptions _emailOptions;
private readonly IEmailProviderResolver _emailProviderResolver;
private readonly ShellSettings _shellSettings;
private readonly IShellReleaseManager _shellReleaseManager;
private readonly EmailProviderOptions _emailProviders;

protected readonly IStringLocalizer S;

public EmailSettingsDisplayDriver(
IHttpContextAccessor httpContextAccessor,
IAuthorizationService authorizationService,
IShellHost shellHost,
IOptions<EmailProviderOptions> emailProviders,
IOptions<EmailOptions> emailOptions,
IEmailProviderResolver emailProviderResolver,
ShellSettings shellSettings,
IShellReleaseManager shellReleaseManager,
IStringLocalizer<EmailSettingsDisplayDriver> stringLocalizer)
{
_httpContextAccessor = httpContextAccessor;
_authorizationService = authorizationService;
_shellHost = shellHost;
_emailOptions = emailOptions.Value;
_emailProviderResolver = emailProviderResolver;
_emailProviders = emailProviders.Value;
_shellSettings = shellSettings;
_shellReleaseManager = shellReleaseManager;
S = stringLocalizer;
}
public override async Task<IDisplayResult> EditAsync(EmailSettings settings, BuildEditorContext context)
Expand Down Expand Up @@ -91,7 +88,7 @@ public override async Task<IDisplayResult> UpdateAsync(EmailSettings settings, U
{
settings.DefaultProviderName = model.DefaultProvider;

await _shellHost.ReleaseShellContextAsync(_shellSettings);
_shellReleaseManager.RequestRelease();
}

return await EditAsync(settings, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EmailMigrations : DataMigration
public int Create()
#pragma warning restore CA1822
{
// In version 1.9, the OrchardCore.Email.Smtp was split from OrchardCore.Email. To ensure we keep the change
// In version 2.0, the OrchardCore.Email.Smtp was split from OrchardCore.Email. To ensure we keep the change
// backward compatible, we added this migration step to auto-enable the new SMTP feature for sites that use the
// Email service and have SmtpSettings.
ShellScope.AddDeferredTask(async scope =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@ namespace OrchardCore.Facebook.Drivers
{
public class FacebookSettingsDisplayDriver : SectionDisplayDriver<ISite, FacebookSettings>
{
private readonly IShellReleaseManager _shellReleaseManager;
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public FacebookSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<FacebookSettingsDisplayDriver> logger
)
{
_shellReleaseManager = shellReleaseManager;
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -87,19 +84,23 @@ public override async Task<IDisplayResult> UpdateAsync(FacebookSettings settings
var model = new FacebookSettingsViewModel();
await context.Updater.TryUpdateModelAsync(model, Prefix);

settings.AppId = model.AppId;
settings.FBInit = model.FBInit;
settings.SdkJs = model.SdkJs;
settings.Version = model.Version;

if (!string.IsNullOrWhiteSpace(model.FBInitParams))
{
settings.FBInitParams = model.FBInitParams;
}

if (context.Updater.ModelState.IsValid)
{
var protector = _dataProtectionProvider.CreateProtector(FacebookConstants.Features.Core);
settings.AppId = model.AppId;
settings.AppSecret = protector.Protect(model.AppSecret);
settings.FBInit = model.FBInit;
settings.SdkJs = model.SdkJs;
if (!string.IsNullOrWhiteSpace(model.FBInitParams))
settings.FBInitParams = model.FBInitParams;
settings.Version = model.Version;

await _shellHost.ReleaseShellContextAsync(_shellSettings);
}

_shellReleaseManager.RequestRelease();
}

return await EditAsync(settings, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ namespace OrchardCore.Facebook.Login.Drivers
{
public class FacebookLoginSettingsDisplayDriver : SectionDisplayDriver<ISite, FacebookLoginSettings>
{
private readonly IShellReleaseManager _shellReleaseManager;
private readonly IAuthorizationService _authorizationService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;

public FacebookLoginSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IAuthorizationService authorizationService,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings)
IHttpContextAccessor httpContextAccessor)
{
_shellReleaseManager = shellReleaseManager;
_authorizationService = authorizationService;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
}

public override async Task<IDisplayResult> EditAsync(FacebookLoginSettings settings, BuildEditorContext context)
Expand Down Expand Up @@ -56,15 +53,15 @@ public override async Task<IDisplayResult> UpdateAsync(FacebookLoginSettings set
}

var model = new FacebookLoginSettingsViewModel();

await context.Updater.TryUpdateModelAsync(model, Prefix);

if (context.Updater.ModelState.IsValid)
{
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);
}
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;

_shellReleaseManager.RequestRelease();
}

return await EditAsync(settings, context);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ namespace OrchardCore.GitHub.Drivers
{
public class GitHubAuthenticationSettingsDisplayDriver : SectionDisplayDriver<ISite, GitHubAuthenticationSettings>
{
private readonly IShellReleaseManager _shellReleaseManager;
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public GitHubAuthenticationSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<GitHubAuthenticationSettingsDisplayDriver> logger)
{
_shellReleaseManager = shellReleaseManager;
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -97,9 +94,11 @@ public override async Task<IDisplayResult> UpdateAsync(GitHubAuthenticationSetti
settings.ClientSecret = protector.Protect(model.ClientSecret);
settings.CallbackPath = model.CallbackUrl;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);

_shellReleaseManager.RequestRelease();
}
}

return await EditAsync(settings, context);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ namespace OrchardCore.Google.Authentication.Drivers
{
public class GoogleAuthenticationSettingsDisplayDriver : SectionDisplayDriver<ISite, GoogleAuthenticationSettings>
{
private readonly IShellReleaseManager _shellReleaseManager;
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public GoogleAuthenticationSettingsDisplayDriver(
IShellReleaseManager shellReleaseManager,
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<GoogleAuthenticationSettingsDisplayDriver> logger)
{
_shellReleaseManager = shellReleaseManager;
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -89,17 +86,20 @@ public override async Task<IDisplayResult> UpdateAsync(GoogleAuthenticationSetti
var model = new GoogleAuthenticationSettingsViewModel();
await context.Updater.TryUpdateModelAsync(model, Prefix);

settings.ClientID = model.ClientID;
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;

if (context.Updater.ModelState.IsValid)
{
var protector = _dataProtectionProvider.CreateProtector(GoogleConstants.Features.GoogleAuthentication);

settings.ClientID = model.ClientID;
settings.ClientSecret = protector.Protect(model.ClientSecret);
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);
}

_shellReleaseManager.RequestRelease();
}

return await EditAsync(settings, context);
}
}
Expand Down
Loading

0 comments on commit 264c301

Please sign in to comment.