2017-10-20 13:30:01 -04:00
|
|
|
var angular = require('angular');
|
|
|
|
|
2017-10-14 15:16:58 -04:00
|
|
|
angular.module('NavCtrl', ['AuthSvc']).controller('NavController', ['$scope', '$window', 'AuthService', function($scope, $window, AuthService) {
|
2017-10-18 13:31:08 -04:00
|
|
|
$scope.user = {};
|
|
|
|
AuthService.currentUser(function(user) {
|
|
|
|
$scope.user = user;
|
|
|
|
});
|
|
|
|
|
2017-10-14 15:16:58 -04:00
|
|
|
$scope.logout = AuthService.logout;
|
|
|
|
|
|
|
|
$scope.hasPermission = function(permission) {
|
2017-10-18 13:31:08 -04:00
|
|
|
if (!$scope.user.scope) return false;
|
|
|
|
return $scope.user.scope.indexOf(permission) !== -1;
|
2017-10-14 15:16:58 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}]);
|