Fix bugs in updateuser

1) Also check for matching organization names
2) Ensure that errors don't leave the throbber
This commit is contained in:
Joseph Schorr 2017-12-01 14:58:29 -05:00
parent c383ac1f9d
commit 4db1615d94
2 changed files with 18 additions and 7 deletions

View file

@ -149,7 +149,6 @@ class Organization(ApiResource):
}, },
} }
@require_scope(scopes.ORG_ADMIN)
@nickname('getOrganization') @nickname('getOrganization')
def get(self, orgname): def get(self, orgname):
""" Get the details for the specified organization """ """ Get the details for the specified organization """

View file

@ -35,19 +35,31 @@
'username': username 'username': username
}; };
var oparams = {
'orgname': username
};
ApiService.getUserInformation(null, params).then(function() { ApiService.getUserInformation(null, params).then(function() {
$scope.state = 'existing'; $scope.state = 'existing';
}, function(resp) { }, function(resp) {
if (resp.status == 404) { ApiService.getOrganization(null, oparams).then(function() {
$scope.state = 'confirmed'; $scope.state = 'existing';
} else { }, function() {
$scope.state = 'error'; if (resp.status == 404) {
} $scope.state = 'confirmed';
} else {
$scope.state = 'error';
}
});
}); });
}; };
$scope.updateUser = function(data) { $scope.updateUser = function(data) {
$scope.state = 'updating'; $scope.state = 'updating';
var errorHandler = ApiService.errorDisplay('Could not update user information', function() {
$scope.state = 'editing';
});
ApiService.changeUserDetails(data).then(function() { ApiService.changeUserDetails(data).then(function() {
UserService.load(function(updated) { UserService.load(function(updated) {
if (updated && updated.prompts && updated.prompts.length) { if (updated && updated.prompts && updated.prompts.length) {
@ -56,7 +68,7 @@
$location.url('/'); $location.url('/');
} }
}); });
}, ApiService.errorDisplay('Could not update user information')); }, errorHandler);
}; };
$scope.hasPrompt = function(user, prompt_name) { $scope.hasPrompt = function(user, prompt_name) {