Skip to content

services authorizationService

Kristijan Horvat edited this page Feb 9, 2017 · 15 revisions

baasicAuthorizationService

Baasic Authorization Service provides an easy way to consume Baasic Application Authorization REST API end-points.


baasicAuthorizationService.getUser()

Gets the currently logged in user.

Example:

baasicAuthorizationService.getUser();

baasicAuthorizationService.setUser()

Sets the current user information. If no user information is provided, the user information will be cleared from the storage and rootScope.

Example:

baasicAuthorizationService.setUser(null);

baasicAuthorizationService.updateUser()

Updates current user information with new data.

Example:

baasicLoginService.loadUserData()
.success(function (data) {
  // Update user information with refreshed data
  baasicAuthorizationService.updateUser(data);
})
.error(function (data) {})
.finally (function () {});				

baasicAuthorizationService.getAccessToken()

Retrives current user's access token.

Example:

baasicAuthorizationService.getAccessToken();

baasicAuthorizationService.updateAccessToken()

Stores access token information.

Example:

baasicLoginService.login({
  username : '<username>',
  password : '<password>',
  options : ['session', 'sliding']
})
.success(function (data) {
  // Store token information
  baasicAuthorizationService.updateAccessToken(data);
})
.error(function (data, status) {})
.finally (function () {});				

baasicAuthorizationService.resetPermissions()

Retrives user permission hash. This action should be performed when user information is updated.

Example:

baasicLoginService.loadUserData()
.success(function (data) {
  baasicAuthorizationService.resetPermissions();
  baasicAuthorizationService.updateUser(data);
})
.error(function (data) {})
.finally (function () {});				

baasicAuthorizationService.hasPermission()

Checks if current user has permissions to perform a certain action. To optimize performance this information is cached and can be reset using the resetPermissions action. Permissions cache should be reset when updated user information is set.

Example:

baasicAuthorizationService.hasPermission("<baasic-Section>.<action>");