0

I have a route setup in AngularJS that looks something like this:

$routeProvider
            .when('/aaa/bbb', {
                templateUrl: 'app/aaa/aaa.html',
                controller: 'AaaCtrl'
            });

Now whenever a user visits /aaa/bbb the user should only be able to visit if the user is logged in, otherwise the user should be redirected to /login. After login in the user should be redirected to /aaa/bbb as originally requested.

I know this is possible to do with connect-ensure-login but I don't understand how to setup the routing with Express? In Express all my routes are setup to be /api routes not the routes the end-user are visisting like /aaa/bbb

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • is this helpful for you ? [Angular router redirect](http://stackoverflow.com/questions/11541695/redirecting-to-a-certain-route-based-on-condition) – alexandru.pausan Jul 10 '15 at 15:04
  • Basically that sets up a watcher for the route, and every time the route changes you can check if the user is logged in. You can adapt it to your own case, and at the login (if you have a flag set in case you needed to login), you can tell it to go the the route before the original redirect. – alexandru.pausan Jul 10 '15 at 15:07

0 Answers0