Skip to content

Commit f3bbf45

Browse files
committed
Merge pull request #7 from nachaos/feature/AclService-getRoles
Adding AclService.getRoles() method
2 parents 56477bc + 53431af commit f3bbf45

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

angular-acl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ angular.module('mm.acl').provider('AclService', [
158158
return (data.roles.indexOf(role) > -1);
159159
};
160160

161+
/**
162+
* Returns the current user roles
163+
* @returns {Array}
164+
*/
165+
AclService.getRoles = function () {
166+
return data.roles;
167+
};
168+
161169
/**
162170
* Set the abilities object (overwriting previous abilities)
163171
*

angular-acl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-acl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ angular.module('mm.acl').provider('AclService', [
171171
return (data.roles.indexOf(role) > -1);
172172
};
173173

174+
/**
175+
* Returns the current user roles
176+
* @returns {Array}
177+
*/
178+
AclService.getRoles = function () {
179+
return data.roles;
180+
};
181+
174182
/**
175183
* Set the abilities object (overwriting previous abilities)
176184
*

test/unit/angular-acl_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ describe('AclService', function () {
9393

9494
});
9595

96+
describe('getRoles()', function () {
97+
98+
it('should return all the roles in current session', function () {
99+
AclService._data.roles = ['foo', 'bar'];
100+
expect(AclService.getRoles()).toEqual(['foo', 'bar']);
101+
});
102+
103+
});
104+
96105
describe('setAbilities()', function () {
97106

98107
it('should set given param to abilities', function () {

0 commit comments

Comments
 (0)