35948

Route and subroute based on user in hottowel asp.net mvc4

Question:

<strong>:updated</strong>

can anyone help me found out how to create routes and subroute based on user is it possible to create a <a href="http://durandaljs.com/documentation/Creating-A-Widget/" rel="nofollow"><strong><em>Widget</em></strong></a> that will do the job if so how

this is how my <strong>menu</strong> looks like (note:all menu items together let us call it <strong>master</strong>):

-Home -shop -men -women -food -dog -human -cart -settings -user -images -themes

let say i have the following userGroup:

-Admin -visitors -vip -costumers -co-workers

what i want to do ist some thing like

if(user == Admin){ destroy the current menu then make a copy of master **master** remove subroute women and subroute dog then push }else if(user == visitor){ ... }

or is there a better way to do this and where i am supose to define it?

Answer1:

First you might want to consider upgrading your project to Durandal 2.0 since it removes the dependency on sammy.js in favor of a custom router which works much better (Durandal 1.0 is essentially obsolete now). Here is the page on upgrading: <a href="http://durandaljs.com/documentation/Conversion-Guide/" rel="nofollow">http://durandaljs.com/documentation/Conversion-Guide/</a>

and here are the docs on the new router: <a href="http://durandaljs.com/documentation/Using-The-Router/" rel="nofollow">http://durandaljs.com/documentation/Using-The-Router/</a>

As for handling the routing based on user, since router.map just expects an array of routes you can just build up the array conditionally and pass it to router.map

var routes = [ { route: '', moduleId: 'hello/index', title: 'Hello World', nav: true }, { route: 'men', moduleId: 'men/index', title: 'Men', nav: true }] if(user == Admin){ routes.push({ route: 'admin', moduleId: 'admin/index', title: 'Admin', nav: true } }else if(user == visitor){ routes.push({ route: 'women', moduleId: 'women/index', title: 'women', nav: true } } return router.map(routes) .buildNavigationModel() .mapUnknownRoutes('hello/index', 'not-found') .activate();

Recommend

  • Route and subroute based on user in hottowel asp.net mvc4
  • Transform SQL Select to Entity Framework Join across five tables
  • Laravel 4 automatically create relationships in BaseModel - using “with”-array or scopes or what?
  • Why aren't these values being added to my array as strings?
  • Error: volttron.platform.web INFO: Web server not started
  • How to subtract seconds from postgres datetime without having to add it in group by clause?
  • How to join 3 tables with linq
  • Yahoo CSV to HTML via PHP — no longer works
  • Error with a Symfony query : Expected Literal, got '\"'
  • Java FastXML JSON library: How to parse a nested JSON structure
  • SelectMany makes too many queries
  • Code Addition is Slowing Page Down
  • Show recently visited html pages by any visitor
  • Google Analytics API - Filtering via .NET - So Close!
  • PHP: I get a completely blank page, I don't know how to debug this in PHP
  • Why is django manage.py syncdb failing to create new columns on my development server?
  • Changing Jupyter Notebook start up folder by modifying “start in” not working any more
  • Configure nginx to return different files to different authenticated users with the same URI
  • How to override value that appears in a dropdown in the rails_admin gem
  • How to get Eclipse Oxygen to run on Java 9
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Syntax for setting draggablecursor property in google maps api
  • GridView Sorting works once only
  • XCode can't find symbols for a specific iOS library/framework project
  • How to get icons for entities from eclipse?
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF