1

I'm trying to prevent navigating to most of my sites' pages when user is not yet logged in. So this is the code I started to write to solve that issue:

router.on("router:navigation:processing", function (instruction, usedRouter) {

    if (!userLoggedIn && instruction.config.moduleId !== "login") {
        router.navigate('login'); //no better way???
    }
}

I would like to find a better alternative to the "router.navigate()"... Didn't find any instruction.cancelNavigation() or anything like that...

chrisdot
  • 659
  • 6
  • 19
  • possible duplicate of [Conditional routing in Durandal](http://stackoverflow.com/questions/19119544/conditional-routing-in-durandal) – Matthew James Davis Dec 10 '14 at 16:18
  • Thanks Matthew, this seems to be the apropriate way to go, even if I'm experiencing some other problems using that. Seems that using the default route ("") breaks the navigation. – chrisdot Dec 12 '14 at 15:36

1 Answers1

0

OK, linked to Conditional routing in Durandal (see how to code it and the official doc about it)

Thanks @Matthew !

Community
  • 1
  • 1
chrisdot
  • 659
  • 6
  • 19