TagHelperPack icon indicating copy to clipboard operation
TagHelperPack copied to clipboard

Updates to display, editor and authz tag helpers

Open MSingh-13 opened this issue 8 months ago • 3 comments

Hi @DamianEdwards

I would appreciate it if you would review and consider merging these updates into the next version of the library.

  1. Updated editor and display tag helpers to accept class and style attributes. This allows adding classes and styles to the tag helpers as normal html attributes (with IntelliSense support). The values are passed to the editor/display template as an anonymous object on the htmlAttributes property of the ViewData which is how they were passed when using editor templates in MVC5. This allowed me to reuse my existing editor/display templates from MVC5 with minimal changes. I used a modified version of the MergeHtmlAttributes extension created by Chris Pratt. https://web.archive.org/web/20211205165309/https://cpratt.co/html-editorfor-and-htmlattributes/ (the original site is currently not accessible)

  2. Updated AuthzTagHelper to handle authorizations based on User roles and permissions. I have updated the TagHelperPack.Sample project to demo these use cases. a) User role is checked using the Principal.IsInRole() method provided by the framework. b) Permission is checked in an authorization policy based on the permissions associated with the current user role.

MSingh-13 avatar Jun 16 '24 12:06 MSingh-13