Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For those looking for an answer or at least a quick fix. Here's what I've come up with after 5 minutes and I most certainly haven't though about any side effects this may have. </p> <pre><code>routes.MapNavigationRoute&lt;HomeController&gt;("Index", c =&gt; c.Index()) .FilterRoute(() =&gt; !WebSecurity.IsAuthenticated); </code></pre> <p>You can either do all your filtering in your call to FilterRoute() or you can add more extension methods to save you some characters.</p> <p>I'm thinking of .RequireRole("Adiministrators"); that calls WebSecurity.RequireRoles() in turn (or HttpContext.Current.User.IsInRole()) etc.</p> <pre><code>public static NavigationRouteBuilder FilterRoute(this NavigationRouteBuilder builder, Func&lt;bool&gt; func) { var currentRoute = builder._parent; NavigationRoutes.Filters.Add(new BootstrapAuthorizationFilter(builder, x =&gt; { if (x == currentRoute) return func(); else return false; })); return builder; } </code></pre> <p>and BootstrapAuthorizationFilter is just a class implementing INavigationRouteFilter that calls func() in its ShouldRemove() method</p> <pre><code>public class BootstrapAuthorizationFilter : INavigationRouteFilter { private NavigationRouteBuilder builder; private Func&lt;NamedRoute, bool&gt; func; public BootstrapAuthorizationFilter(NavigationRouteBuilder builder, Func&lt;NamedRoute, bool&gt; func) { this.builder = builder; this.func = func; } public bool ShouldRemove(Route navigationRoutes) { if (navigationRoutes is NamedRoute) return func(navigationRoutes as NamedRoute); return false; } } </code></pre> <p>Clearly nothing fancy and I'm not sure if I'd use it in production. But I think is simple enough and works (for the cases I tested). Having said that, I hope the new routing functionality is going to be released soon :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload