Handlers to redirect creating and editing users to the correct controller (#8549)

This commit is contained in:
Matteo Piovanelli 2022-04-01 14:15:04 +02:00 committed by GitHub
parent a5f657540a
commit c0fa82fcf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
using Orchard.Users.Models;
using System.Web.Routing;
namespace Orchard.Users.Handlers {
public class UserPartHandler : ContentHandler {
@ -16,6 +17,19 @@ namespace Orchard.Users.Handlers {
if (part != null) {
context.Metadata.Identity.Add("User.UserName", part.UserName);
context.Metadata.DisplayText = part.UserName;
// Configure routing metadata to make back-office experience more robust
context.Metadata.CreateRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Users"},
{"Controller", "Admin"},
{"Action", "Create"}
};
context.Metadata.EditorRouteValues = new RouteValueDictionary {
{"Area", "Orchard.Users"},
{"Controller", "Admin"},
{"Action", "Edit"},
{"id", context.ContentItem.Id}
};
}
}
}