Skip to content

Commit

Permalink
Merge branch 'ma/prevent-external-registration' of https://github.com…
Browse files Browse the repository at this point in the history
…/OrchardCMS/OrchardCore into ma/prevent-external-registration
  • Loading branch information
MikeAlhayek committed Nov 25, 2024
2 parents 34af071 + 3f08e14 commit 3a20398
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,13 @@ public async Task<IActionResult> DiscardDraft(string contentItemId, string retur
return Forbid();
}

if (contentItem != null)
{
await _contentManager.DiscardDraftAsync(contentItem);
await _contentManager.DiscardDraftAsync(contentItem);

var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);
var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);

await _notifier.SuccessAsync(string.IsNullOrWhiteSpace(typeDefinition?.DisplayName)
? H["The draft has been removed."]
: H["The {0} draft has been removed.", typeDefinition.DisplayName]);
}
await _notifier.SuccessAsync(string.IsNullOrWhiteSpace(typeDefinition?.DisplayName)
? H["The draft has been removed."]
: H["The {0} draft has been removed.", typeDefinition.DisplayName]);

return Url.IsLocalUrl(returnUrl)
? this.LocalRedirect(returnUrl, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,19 @@ Task<IDisplayResult> IContentFieldDisplayDriver.BuildEditorAsync(ContentPart con

var field = contentPart.GetOrCreate<TField>(partFieldDefinition.Name);

if (field != null)
{
BuildPrefix(typePartDefinition, partFieldDefinition, context.HtmlFieldPrefix);
BuildPrefix(typePartDefinition, partFieldDefinition, context.HtmlFieldPrefix);

var fieldEditorContext = new BuildFieldEditorContext(contentPart, typePartDefinition, partFieldDefinition, context);
var fieldEditorContext = new BuildFieldEditorContext(contentPart, typePartDefinition, partFieldDefinition, context);

_typePartDefinition = typePartDefinition;
_partFieldDefinition = partFieldDefinition;
_typePartDefinition = typePartDefinition;
_partFieldDefinition = partFieldDefinition;

var result = EditAsync(field, fieldEditorContext);
var result = EditAsync(field, fieldEditorContext);

_typePartDefinition = null;
_partFieldDefinition = null;

return result;
}
_typePartDefinition = null;
_partFieldDefinition = null;

return Task.FromResult(default(IDisplayResult));
return result;
}

async Task<IDisplayResult> IContentFieldDisplayDriver.UpdateEditorAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,14 @@ private async Task ApplyImplementationAsync(BuildShapeContext context, string di
newShapeMetadata.Wrappers.Clear();
}

if (placement != null)
if (placement.Alternates != null)
{
if (placement.Alternates != null)
{
newShapeMetadata.Alternates.AddRange(placement.Alternates);
}
newShapeMetadata.Alternates.AddRange(placement.Alternates);
}

if (placement.Wrappers != null)
{
newShapeMetadata.Wrappers.AddRange(placement.Wrappers);
}
if (placement.Wrappers != null)
{
newShapeMetadata.Wrappers.AddRange(placement.Wrappers);
}

var parentShape = context.Shape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public async Task AddSourcesAsync(string tenant, IConfigurationBuilder builder)
if (configuration is not null)
{
var configurationString = configuration.ToJsonString(JOptions.Default);
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(configurationString));

builder.AddTenantJsonStream(stream);
builder.AddTenantJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(configurationString)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public async Task AddSourcesAsync(IConfigurationBuilder builder)
if (document.ShellsSettings is not null)
{
var shellsSettingsString = document.ShellsSettings.ToJsonString(JOptions.Default);
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(shellsSettingsString));

builder.AddTenantJsonStream(stream);
builder.AddTenantJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(shellsSettingsString)));
}
}

Expand All @@ -55,9 +53,7 @@ public async Task AddSourcesAsync(string tenant, IConfigurationBuilder builder)
{
var shellSettings = new JsonObject { [tenant] = document.ShellsSettings[tenant] };
var shellSettingsString = shellSettings.ToJsonString(JOptions.Default);
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(shellSettingsString));

builder.AddTenantJsonStream(stream);
builder.AddTenantJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(shellSettingsString)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class CommonPermissions

public static readonly Permission ListUsers = new("ListUsers", "List all users", [EditUsers, DeleteUsers]);

public static readonly Permission AssignRoleToUsers = new("AssignRoleToUsers", "Assign any role to users", [EditUsers], true);
public static readonly Permission AssignRoleToUsers = new("AssignRoleToUsers", "Assign any role to users", true);

public static readonly Permission DisableTwoFactorAuthenticationForUsers = new("DisableTwoFactorAuthenticationForUsers", "Disable two-factor authentication for any user", [ManageUsers], true);

Expand Down
4 changes: 4 additions & 0 deletions src/docs/releases/3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ The following obsolete settings were removed from `LoginSettings` class
#### Login View Update

The `ExternalLogin` action has been removed from the `Account` controller. If you are using a custom `Login.cshtml` view or `Login` template, please update the external login form action. As of this update, the `ExternalLogin` action has been relocated to the `ExternalAuthentications` controller.

#### AssignRoleToUsers Permission Update

The `AssignRoleToUsers` permission is no longer implicitly granted by `EditUsers`. To maintain the same behavior, make sure to explicitly assign the `AssignRoleToUsers` permission to any role that already has the `EditUsers` permission.
2 changes: 1 addition & 1 deletion src/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdocs>=1.6.1
mkdocs-material>=9.5.45
mkdocs-material>=9.5.46
mkdocs-git-authors-plugin>=0.9.2
mkdocs-git-revision-date-localized-plugin>=1.3.0
pymdown-extensions>=10.12.0
Expand Down

0 comments on commit 3a20398

Please sign in to comment.