Skip to content

Commit

Permalink
Minor cleanup on 2.0.0 release notes (OrchardCMS#16462)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Jul 19, 2024
1 parent 27142a0 commit dec01d0
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public ReCaptchaForgotPasswordFormDisplayDriver(ISiteService siteService)

public override async Task<IDisplayResult> EditAsync(ForgotPasswordForm model, BuildEditorContext context)
{
var _reCaptchaSettings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!_reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public ReCaptchaResetPasswordFormDisplayDriver(ISiteService siteService)

public override async Task<IDisplayResult> EditAsync(ResetPasswordForm model, BuildEditorContext context)
{
var _reCaptchaSettings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!_reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public RegisterUserFormDisplayDriver(ISiteService siteService)

public override async Task<IDisplayResult> EditAsync(RegisterUserForm model, BuildEditorContext context)
{
var reCaptchaSettings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,41 @@ public override async Task<IDisplayResult> EditAsync(ReverseProxySettings settin

public override async Task<IDisplayResult> UpdateAsync(ReverseProxySettings settings, UpdateEditorContext context)
{
if (!context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
{
return null;
}

var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageReverseProxySettings))
{
return null;
}

if (context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
{
var model = new ReverseProxySettingsViewModel();

await context.Updater.TryUpdateModelAsync(model, Prefix);
var model = new ReverseProxySettingsViewModel();

settings.ForwardedHeaders = ForwardedHeaders.None;
await context.Updater.TryUpdateModelAsync(model, Prefix);

if (model.EnableXForwardedFor)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedFor;
}
settings.ForwardedHeaders = ForwardedHeaders.None;

if (model.EnableXForwardedHost)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedHost;
}
if (model.EnableXForwardedFor)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedFor;
}

if (model.EnableXForwardedProto)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedProto;
}
if (model.EnableXForwardedHost)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedHost;
}

_shellReleaseManager.RequestRelease();
if (model.EnableXForwardedProto)
{
settings.ForwardedHeaders |= ForwardedHeaders.XForwardedProto;
}

_shellReleaseManager.RequestRelease();

return await EditAsync(settings, context);
}
}
Expand Down
56 changes: 30 additions & 26 deletions src/docs/releases/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class ForgotPasswordLoginFormDisplayDriver : DisplayDriver<LoginForm>

public override async Task<IDisplayResult> EditAsync(LoginForm model, BuildEditorContext context)
{
var settings = (await _siteService.GetSiteSettingsAsync()).As<ResetPasswordSettings>();
var settings = await _siteService.GetSettingsAsync<ResetPasswordSettings>();

if (!settings.AllowResetPassword)
{
Expand All @@ -154,9 +154,9 @@ public class ReCaptchaForgotPasswordFormDisplayDriver : DisplayDriver<ForgotPass

public override async Task<IDisplayResult> EditAsync(ForgotPasswordForm model, BuildEditorContext context)
{
var _reCaptchaSettings = (await _siteService.GetSiteSettingsAsync()).As<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!_reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand All @@ -180,9 +180,9 @@ public class ReCaptchaResetPasswordFormDisplayDriver : DisplayDriver<ResetPasswo

public override async Task<IDisplayResult> EditAsync(ResetPasswordForm model, BuildEditorContext context)
{
var _reCaptchaSettings = (await _siteService.GetSiteSettingsAsync()).As<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!_reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand All @@ -208,9 +208,9 @@ public class RegisterUserFormDisplayDriver : DisplayDriver<RegisterUserForm>

public override async Task<IDisplayResult> EditAsync(RegisterUserForm model, BuildEditorContext context)
{
var _reCaptchaSettings = (await _siteService.GetSiteSettingsAsync()).As<ReCaptchaSettings>();
var settings = await _siteService.GetSettingsAsync<ReCaptchaSettings>();

if (!_reCaptchaSettings.IsValid())
if (!settings.IsValid())
{
return null;
}
Expand Down Expand Up @@ -490,24 +490,26 @@ public class ReverseProxySettingsDisplayDriver : SectionDisplayDriver<ISite, Rev
public override async Task<IDisplayResult> UpdateAsync(ReverseProxySettings section, UpdateEditorContext context)
{
if (!context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
{
return null;
}

var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageReverseProxySettings))
{
return null;
}

if (context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
//
// For example simplicity, other logic are not visible.
//
// If the settings are valid, release the current tenant.
if (context.Updater.ModelState.IsValid)
{
//
// For example simplicity, other logic are not visible.
//
// If the settings are valid, release the current tenant.
if (context.Updater.ModelState.IsValid)
{
await _shellHost.ReleaseShellContextAsync(_shellSettings);
}
await _shellHost.ReleaseShellContextAsync(_shellSettings);
}

return await EditAsync(section, context);
Expand Down Expand Up @@ -541,22 +543,24 @@ public class ReverseProxySettingsDisplayDriver : SectionDisplayDriver<ISite, Rev
public override async Task<IDisplayResult> UpdateAsync(ReverseProxySettings settings, UpdateEditorContext context)
{
if (!context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
{
return null;
}

var user = _httpContextAccessor.HttpContext?.User;

if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageReverseProxySettings))
{
return null;
}

if (context.GroupId.EqualsOrdinalIgnoreCase(GroupId))
{
//
// For example simplicity, other logic are not visible.
//
//
// For example simplicity, other logic are not visible.
//
// (2) Request a release at the end of the request.
_shellReleaseManager.RequestRelease();
}
// (2) Request a release at the end of the request.
_shellReleaseManager.RequestRelease();

return await EditAsync(settings, context);
}
Expand Down Expand Up @@ -618,4 +622,4 @@ A new filter named `supported_cultures` was added to allow you to get a list of

### Sealing Types

Many configuration classes commonly used by modules can be `sealed`, which improves runtime performance. We've implemented this enhancement in [this pull request](https://github.com/OrchardCMS/OrchardCore/pull/16253) and [this one](https://github.com/OrchardCMS/OrchardCore/pull/16238). While it's not mandatory, we recommend that you consider applying this improvement to your own extensions as well.
Many configuration classes commonly used by modules can be `sealed`, which improves runtime performance. We've implemented this enhancement in [this pull request](https://github.com/OrchardCMS/OrchardCore/pull/16253) and [this one](https://github.com/OrchardCMS/OrchardCore/pull/16238). While it's not mandatory, we recommend that you consider applying this improvement to your own extensions as well.

0 comments on commit dec01d0

Please sign in to comment.