From 4db1615d94b13ea7d263444c3c5ab1f6f79bde50 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 1 Dec 2017 14:58:29 -0500 Subject: [PATCH] Fix bugs in updateuser 1) Also check for matching organization names 2) Ensure that errors don't leave the throbber --- endpoints/api/organization.py | 1 - static/js/pages/update-user.js | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/endpoints/api/organization.py b/endpoints/api/organization.py index 9bd0f5126..93cf5ed85 100644 --- a/endpoints/api/organization.py +++ b/endpoints/api/organization.py @@ -149,7 +149,6 @@ class Organization(ApiResource): }, } - @require_scope(scopes.ORG_ADMIN) @nickname('getOrganization') def get(self, orgname): """ Get the details for the specified organization """ diff --git a/static/js/pages/update-user.js b/static/js/pages/update-user.js index 53af7fd9a..f81908db4 100644 --- a/static/js/pages/update-user.js +++ b/static/js/pages/update-user.js @@ -35,19 +35,31 @@ 'username': username }; + var oparams = { + 'orgname': username + }; + ApiService.getUserInformation(null, params).then(function() { $scope.state = 'existing'; }, function(resp) { - if (resp.status == 404) { - $scope.state = 'confirmed'; - } else { - $scope.state = 'error'; - } + ApiService.getOrganization(null, oparams).then(function() { + $scope.state = 'existing'; + }, function() { + if (resp.status == 404) { + $scope.state = 'confirmed'; + } else { + $scope.state = 'error'; + } + }); }); }; $scope.updateUser = function(data) { $scope.state = 'updating'; + var errorHandler = ApiService.errorDisplay('Could not update user information', function() { + $scope.state = 'editing'; + }); + ApiService.changeUserDetails(data).then(function() { UserService.load(function(updated) { if (updated && updated.prompts && updated.prompts.length) { @@ -56,7 +68,7 @@ $location.url('/'); } }); - }, ApiService.errorDisplay('Could not update user information')); + }, errorHandler); }; $scope.hasPrompt = function(user, prompt_name) {