How to do slug routes and protected routes?

I am trying to use slug and action in my route.

when I use from stache for page href="{{routeUrl page=‘pagename’}}“
When I use a slug from stache for page href=”{{ routeUrl page=‘pagename’ slug=‘slugname’ }}“
When I use action from stache for page href=”{{ routeUrl page=‘pagename’ slug=‘slugname’ action=‘actionname’ }}"

When I use in js file for page route.attr({ page: “pagename”, slug: null, action: null });
When I use in js file for slug route.attr({ page: “pagename”, slug: ‘slugname’, action: null });
When I use in js file for action route.attr({ page: “pagename”, slug: ‘slugname’, action: ‘action’ });

I want to try the protected routes as well in donejs.

Hi @surendrababup, I don’t 100% understand what you’re asking about how routes work in JS vs. can-stache.

You can guard against unauthorized users from accessing different routes in a few ways:

  1. Within the component, checking their authorization.
  2. Within your index.stache or equivalent, not loading the component unless they’re authorized.
  3. Within your app.js or equivalent, redirecting the user to a different route if they’re not authorized.

If you want to share some of your code or talk about your goals, we can figure out a good solution. :blush:

Yes, How to redirect from action to slug or page in JS vs. can-stache?

You can set route.data to the properties that match the route you want.