SpRouteConfig
stormpath
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.
If true, the user must be authenticated in order to view this route.
If the user is not authenticated, they will
be redirected to the login route. After they login, they will be redirected to
the route that was originally requested.
If true, delay the route transition until we know
if the user is authenticated or not. This is useful for situations where
you want everyone to see this route, but the route may look different
depending on the user's authentication route.
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'
}
}
});
});