Skip to content

Commit

Permalink
DRY admin-users route config
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource committed Nov 2, 2012
1 parent 34befc1 commit 69ea340
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/app/admin/users/admin-users.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
angular.module('admin-users', ['admin-users-edit', 'services.crud'], ['$routeProvider', function ($routeProvider) {

var currentUser = ['AuthenticationService', function(AuthenticationService) {
return AuthenticationService.requireAuthenticatedUser();
}];

$routeProvider.when('/admin/users', {
templateUrl:'admin/users/users-list.tpl.html',
controller:'UsersListCtrl',
resolve:{
users:['Users', function (Users) {
return Users.all();
}],
currentUser: ['AuthenticationService', function(AuthenticationService) {
return AuthenticationService.requireAuthenticatedUser();
}]
currentUser: currentUser
}
});
$routeProvider.when('/admin/users/new', {
Expand All @@ -19,9 +21,7 @@ angular.module('admin-users', ['admin-users-edit', 'services.crud'], ['$routePro
user:['Users', function (Users) {
return new Users();
}],
currentUser: ['AuthenticationService', function(AuthenticationService) {
return AuthenticationService.requireAdminUser();
}]
currentUser: currentUser
}
});
$routeProvider.when('/admin/users/:userId', {
Expand All @@ -31,9 +31,7 @@ angular.module('admin-users', ['admin-users-edit', 'services.crud'], ['$routePro
user:['$route', 'Users', function ($route, Users) {
return Users.getById($route.current.params.userId);
}],
currentUser: ['AuthenticationService', function(AuthenticationService) {
return AuthenticationService.requireAdminUser();
}]
currentUser: currentUser
}
});
}]);
Expand Down

0 comments on commit 69ea340

Please sign in to comment.