Skip to content

Commit

Permalink
Merge branch 'main' into ma/role-migrations-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco authored Jan 23, 2025
2 parents 231984b + e0842a9 commit 0592109
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
@using Microsoft.AspNetCore.Identity
@using OrchardCore.DisplayManagement.ModelBinding
@using OrchardCore.Entities
@using OrchardCore.Settings
@using OrchardCore.Users
@using OrchardCore.Users.Models

@inject SignInManager<IUser> SignInManager
@inject UserManager<IUser> UserManager
@inject IDisplayManager<LoginForm> LoginFormDisplayManager
@inject IUpdateModelAccessor UpdateModelAccessor

@{
ViewLayout = "Layout__Login";

var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
var loginProviders = await SignInManager.GetExternalAuthenticationSchemesAsync();
var disableLocalLogin = Site.As<LoginSettings>().DisableLocalLogin;
var hasExternalProviders = loginProviders.Any();
}

<script asp-name="font-awesome" at="Foot" version="6"></script>
Expand All @@ -29,12 +23,15 @@

@if (!disableLocalLogin)
{
<div class="col-md-6 @(loginProviders.Count == 0 ? "offset-md-3" : string.Empty)">
<div class="col-md-6 @(!hasExternalProviders ? "offset-md-3" : string.Empty)">
<h1 class="fs-4">@T["Log in"]</h1>
<hr />

@await DisplayAsync(Model)
</div>
}

@if (loginProviders.Count > 0)
@if (hasExternalProviders)
{
<div class="col-md-6 @(disableLocalLogin ? "offset-md-3" : string.Empty)">
<section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

<form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="auth-form no-multisubmit">
<h1 class="fs-4">@T["Log in"]</h1>
<hr />
<form asp-controller="Account" asp-action="Login" asp-area="OrchardCore.Users" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="auth-form no-multisubmit">

@if (Model.Content != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace OrchardCore.ResourceManagement;

internal static class ResourceManagementConstants
{
public static readonly char[] ParameterValuesSeparator = [',', ' '];

public const char VersionSeparator = ':';
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace OrchardCore.ResourceManagement.TagHelpers;
[HtmlTargetElement("script", Attributes = AtAttributeName)]
public class ScriptTagHelper : TagHelper
{
private static readonly char[] _separator = [',', ' '];

private const string NameAttributeName = "asp-name";
private const string SrcAttributeName = "asp-src";
private const string AtAttributeName = "at";
Expand Down Expand Up @@ -108,7 +106,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
// This allows additions to the pre registered scripts dependencies.
if (!string.IsNullOrEmpty(DependsOn))
{
setting.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
setting.SetDependencies(DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

// Allow Inline to work with both named scripts, and named inline scripts.
Expand Down Expand Up @@ -161,11 +159,11 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu

if (!string.IsNullOrEmpty(DependsOn))
{
var dependencies = DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
var dependencies = DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);

foreach (var dependency in dependencies)
{
var versionParts = dependency.Split(':');
var versionParts = dependency.Split(ResourceManagementConstants.VersionSeparator, 2);

var resourceName = versionParts[0];

Expand Down Expand Up @@ -215,12 +213,12 @@ private void PopulateResourceDefinition(ResourceDefinition definition)

if (!string.IsNullOrEmpty(Culture))
{
definition.SetCultures(Culture.Split(_separator, StringSplitOptions.RemoveEmptyEntries));
definition.SetCultures(Culture.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.RemoveEmptyEntries));
}

if (!string.IsNullOrEmpty(DependsOn))
{
definition.SetDependencies(DependsOn.Split(_separator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
definition.SetDependencies(DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

if (AppendVersion.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace OrchardCore.ResourceManagement.TagHelpers;
[HtmlTargetElement("style", Attributes = AtAttributeName)]
public class StyleTagHelper : TagHelper
{
private static readonly char[] _splitSeparators = [',', ' '];
private const string NameAttributeName = "asp-name";
private const string SrcAttributeName = "asp-src";
private const string AtAttributeName = "at";
Expand Down Expand Up @@ -94,7 +93,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu

if (!string.IsNullOrEmpty(DependsOn))
{
setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
setting.SetDependencies(DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

if (At == ResourceLocation.Inline)
Expand Down Expand Up @@ -158,7 +157,7 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
// This allows additions to the pre registered style dependencies.
if (!string.IsNullOrEmpty(DependsOn))
{
setting.SetDependencies(DependsOn.Split(_splitSeparators, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
setting.SetDependencies(DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

var childContent = await output.GetChildContentAsync();
Expand Down Expand Up @@ -200,12 +199,12 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu

if (!string.IsNullOrEmpty(Culture))
{
definition.SetCultures(Culture.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
definition.SetCultures(Culture.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

if (!string.IsNullOrEmpty(DependsOn))
{
definition.SetDependencies(DependsOn.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
definition.SetDependencies(DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
}

// Also include the style.
Expand Down Expand Up @@ -256,11 +255,11 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu

if (!string.IsNullOrEmpty(DependsOn))
{
var dependencies = DependsOn.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
var dependencies = DependsOn.Split(ResourceManagementConstants.ParameterValuesSeparator, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);

foreach (var dependency in dependencies)
{
var versionParts = dependency.Split(':');
var versionParts = dependency.Split(ResourceManagementConstants.VersionSeparator, 2);

var resourceName = versionParts[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Jint.Runtime.Interop;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;

namespace OrchardCore.Scripting.JavaScript;

Expand Down Expand Up @@ -39,8 +40,15 @@ public IScriptingScope CreateScope(IEnumerable<GlobalMethod> methods, IServicePr
return ObjectWrapper.Create(e, (JsonValue)dynamicValue, type);
}

if (target is StringValues stringValues)
{
return ObjectWrapper.Create(e, stringValues.Count <= 1 ? stringValues.ToString() : stringValues.ToArray(), type);
}

return ObjectWrapper.Create(e, target, type);
});


});

foreach (var method in methods)
Expand Down
11 changes: 11 additions & 0 deletions src/docs/releases/3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ will return `false` for administrators, even though they still have full access.
{% assign isAuthorized = User | has_permission: "AccessAdminPanel" %}
```

#### LoginForm_Edit Shape Type Modification

To simplify the `LoginForm.Edit.cshtml` view, the following code has been moved to `Views/Account/Login.cshtml`:

```html
<h1 class="fs-4">@T["Log in"]</h1>
<hr />
```

If you are overriding the `Views/Account/Login.cshtml` view, you may want to add the above code to your custom version for consistency.

### ReCaptcha

In the previous implementation, the ReCaptcha module supported two modes: `AlwaysShow` and `PreventRobots`. To simplify the module and enhance integration, the `PreventRobots` mode and its related components have been removed. Going forward, **only the `AlwaysShow` mode** will be supported.
Expand Down

0 comments on commit 0592109

Please sign in to comment.