From 69ea3405d5aa1f0b3a892824254de1857dceaef7 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Fri, 2 Nov 2012 20:18:57 +0100 Subject: [PATCH] DRY admin-users route config --- src/app/admin/users/admin-users.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/admin/users/admin-users.js b/src/app/admin/users/admin-users.js index 9c6ade18..d1b6fd02 100644 --- a/src/app/admin/users/admin-users.js +++ b/src/app/admin/users/admin-users.js @@ -1,5 +1,9 @@ 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', @@ -7,9 +11,7 @@ angular.module('admin-users', ['admin-users-edit', 'services.crud'], ['$routePro users:['Users', function (Users) { return Users.all(); }], - currentUser: ['AuthenticationService', function(AuthenticationService) { - return AuthenticationService.requireAuthenticatedUser(); - }] + currentUser: currentUser } }); $routeProvider.when('/admin/users/new', { @@ -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', { @@ -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 } }); }]);