diff options
| author | AppaRao Puli <apparao.puli@linux.intel.com> | 2018-12-27 16:17:46 +0530 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-01-02 01:12:37 +0000 |
| commit | cf7219ce64d600d10b1de4eca1f0c690dfb32344 (patch) | |
| tree | 03f722f3eb2687408f19e9aff15d48079d3fd96a /app/common/services | |
| parent | 28711a6ad2cff8277bfa537c3b140caf690ab575 (diff) | |
| download | phosphor-webui-cf7219ce64d600d10b1de4eca1f0c690dfb32344.tar.gz phosphor-webui-cf7219ce64d600d10b1de4eca1f0c690dfb32344.zip | |
WebUI: Dynamically get accountService roles
Get the AccountService roles dynamically
by calling redfish/rest API's and use them
in user management webui.
Test:
Loaded web page and checked user management
page for appropriate roles fetched from dbus.
Change-Id: I4f51cb0a622a1be8b0bfec2b2fe3ecdee2538c6a
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Diffstat (limited to 'app/common/services')
| -rw-r--r-- | app/common/services/api-utils.js | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js index beb63ba..908dd27 100644 --- a/app/common/services/api-utils.js +++ b/app/common/services/api-utils.js @@ -526,7 +526,62 @@ window.angular && (function(angular) { return deferred.promise; } }, - getAllUserAccounts: function(members) { + getAccountServiceRoles: function() { + var roles = []; + + if (DataService.configJson.redfishSupportEnabled == true) { + return $http({ + method: 'GET', + url: DataService.getHost() + + '/redfish/v1/AccountService/Roles', + withCredentials: true + }) + .then( + function(response) { + var members = response.data['Members']; + angular.forEach(members, function(member) { + roles.push(member['@odata.id'].split('/').pop()); + }); + return roles; + }, + function(error) { + console.log(error); + }); + } else { + return $http({ + method: 'GET', + url: DataService.getHost() + '/xyz/openbmc_project/user', + withCredentials: true + }) + .then( + function(response) { + var json = JSON.stringify(response.data); + var content = JSON.parse(json); + var privList = content.data['AllPrivileges']; + + function convertPrivToRoleId(priv) { + if (priv == 'priv-admin') { + return 'Administrator'; + } else if (priv == 'priv-user') { + return 'User'; + } else if (priv == 'priv-operator') { + return 'Operator'; + } else if (priv == 'priv-callback') { + return 'Callback'; + } + return ''; + } + for (var i = 0; i < privList.length; i++) { + roles.push(convertPrivToRoleId(privList[i])); + } + return roles; + }, + function(error) { + console.log(error); + }); + } + }, + getAllUserAccounts: function() { var deferred = $q.defer(); var promises = []; var users = []; |

