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 = {};
|
2018-08-14 05:14:26 -04:00
|
|
|
AuthService.whoami(data => {
|
|
|
|
$scope.user = data;
|
2017-10-18 13:31:08 -04:00
|
|
|
});
|
|
|
|
|
2017-10-14 15:16:58 -04:00
|
|
|
$scope.logout = AuthService.logout;
|
|
|
|
|
|
|
|
$scope.hasPermission = function(permission) {
|
2018-01-15 18:13:59 -05:00
|
|
|
return ($scope.user && $scope.user.scope &&
|
|
|
|
$scope.user.scope.indexOf(permission) !== -1);
|
2017-10-14 15:16:58 -04:00
|
|
|
};
|
|
|
|
}]);
|