mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-10 10:01:48 -05:00
30 day trial modifiations. Refactored Access helper and created a new License helper. Removed ansible/License module. Created a new license viewer that allows admin user to update the license key. Nag message at login now differentiates between admin and non-admin user.
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
/******************************************************
|
|
* Copyright (c) 2014 AnsibleWorks, Inc.
|
|
*
|
|
* helpers/Access.js
|
|
*
|
|
* Routines for checking user access
|
|
*
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
angular.module('AccessHelper', ['RestServices', 'Utilities'])
|
|
|
|
.factory('CheckAccess', ['$rootScope', 'Alert', 'Rest', 'GetBasePath', 'ProcessErrors', function ($rootScope, Alert, Rest, GetBasePath, ProcessErrors) {
|
|
return function (params) {
|
|
// set PermissionAddAllowed to true or false based on user access. admins and org admins are granted
|
|
// accesss.
|
|
var me = $rootScope.current_user,
|
|
scope = params.scope;
|
|
|
|
if (me.is_superuser) {
|
|
scope.PermissionAddAllowed = true;
|
|
} else {
|
|
if (me.related.admin_of_organizations) {
|
|
Rest.setUrl(me.related.admin_of_organizations);
|
|
Rest.get()
|
|
.success(function (data) {
|
|
if (data.results.length > 0) {
|
|
scope.PermissionAddAllowed = true;
|
|
} else {
|
|
scope.PermissionAddAllowed = false;
|
|
}
|
|
})
|
|
.error(function (data, status) {
|
|
ProcessErrors(scope, data, status, null, {
|
|
hdr: 'Error!',
|
|
msg: 'Call to ' + me.related.admin_of_organizations +
|
|
' failed. DELETE returned status: ' + status
|
|
});
|
|
});
|
|
}
|
|
}
|
|
//if (!access) {
|
|
// Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
|
//}
|
|
//return access;
|
|
};
|
|
}])
|
|
|
|
.factory('IsAdmin', ['$rootScope', function($rootScope) {
|
|
return function() { return ($rootScope.current_user && $rootScope.current_user.is_superuser); };
|
|
}]);
|