Improve this doc View source

SpRouteConfig
object in module stormpath

Description

The Stormpath Route Config is an object that you can define on a route. Use this configuration to define access control for your routes, as defined by the ngRoute module.

You will need to be using the ngRoute module, and you need to enable the integration by calling $stormpath.ngRouter() in your application's config block.

If you're using UI Router instead of Angular's built-in $routeProvider, please use $stormpath.uiRouter() instead.

Properties

Example


angular.module('myApp')
  .config(function ($routeProvider) {
    // Wait until we know if the user is logged in before showing the homepage
    $routeProvider
      .when('/main', {
        controller: 'MainCtrl',
        sp: {
          waitForUser: true
        }
      });

    // Require a user to be authenticated in order to see this route
    $routeProvider
      .when('/secrets', {
        controller: 'SecretsCtrl',
        sp: {
          authenticate: true
        }
      });

    // Require a user to be in the admins group in order to see this route
    $routeProvider
      .when('/secrets', {
        controller: 'AdminCtrl',
        sp: {
          authorize: {
            group: 'admins'
          }
        }
      });
});