title: redirection to profile page as soon as registration is successful
body: <p>Not getting <strong>redirected</strong> to login page my profile page is an html and main is the login page. I tried redirecting it to both the pages but it keeps going to the catch block as soon as a relocation is provided. </p>
  
  <pre><code>angular.module('meanhotel').controller('RegisterController', RegisterController);
  
  function RegisterController($http) {
    var vm = this;
  
    vm.register = function() {
      var user = {
        firstname: vm.firstname,
        lastname: vm.lastname,
        email: vm.email,
        password: vm.password
      };
  
      if (!vm.email || !vm.password) {
        vm.error = 'Please add email and password.';
      } else {
        if (vm.password !== vm.passwordRepeat) {
          vm.error = 'Please make sure the passwords match.';
        } else {
          $http.post('/api/users/register', user).then(function(result) {
            console.log(result);
          //  vm.message = 'Successful registration, please login!';
            vm.error = '';
          // $window.location.href('/main');
          //$location.path('#!/profile');
          $window.location.href = '/main.html';
  
          }).catch(function(error) {
            vm.error = "User already exists";
            console.log(error);
          });
        }
      }
    }
  };
  </code></pre>
  
  <p>app.js:
  routing in app.js is as follows. Profile is a simple html page with a logout button. not sure if the user is getting passed to it as well. I am setting the user in another controller.</p>
  
  <pre><code>angular.module('meanhotel', ['ngRoute', 'angular-jwt']).config(config).run(run);
  
  function config($httpProvider, $routeProvider) {
    $httpProvider.interceptors.push('AuthInterceptor');
  
    $routeProvider
      .when('/', {
        templateUrl: 'angular-app/main/main.html',
        access: {
          restricted: false
        }
      })
      .when('/register', {
        templateUrl: 'angular-app/register/register.html',
        controller: RegisterController,
        controllerAs: 'vm',
        access: {
          restricted: false
        }
      })
    .when('/profile', {
        templateUrl: 'angular-app/profile/profile.html',
        controller: LoginController,
        controllerAs: 'vm',
        access: {
          restricted: true
        }
      })
      .otherwise({
        redirectTo: '/'
      });
  }
  
  appModule.config(['$locationProvider', function($locationProvider) {
    $locationProvider.hashPrefix("");
  }]);
  
  function run($rootScope, $location, $window, AuthFactory) {
    $rootScope.$on('$routeChangeStart', function(event, nextRoute, currentRoute) {
      if (nextRoute.access !== undefined &amp;&amp; nextRoute.access.restricted &amp;&amp; !$window.sessionStorage.token &amp;&amp; !AuthFactory.isLoggedIn) {
        event.preventDefault();
        $location.path('/');
      }
    });
  }
  </code></pre>