Assign project role to the user when the user is created

In the angular create user form page, when the new user is created,
the role selected by the administrator is not assigned to the user,
which will result in the creation of the user can not log in normally.

This patch uses the existing service, when the new user is created,
then Assign project role for the new user.

Change-Id: I52b9bb3bc986cc89439cf22deb1e250a9252938a
Closes-Bug:#1743596
This commit is contained in:
wei.ying 2018-01-17 14:21:20 +08:00 committed by Shu Muto
parent 6340e80465
commit 259648bcf7
2 changed files with 10 additions and 7 deletions

View File

@ -73,14 +73,16 @@
function submit(context) {
return keystone.createUser(context.model).then(success);
}
function success(response) {
var user = response.data;
toast.add('success', interpolate(message.success, [user.name]));
return actionResultService.getActionResult()
.created(resourceType, user.id)
.result;
function success(response) {
var user = response.data;
toast.add('success', interpolate(message.success, [user.name]));
// Assign project role for the new user.
keystone.grantRole(user.default_project_id, context.model.role, user.id);
return actionResultService.getActionResult()
.created(resourceType, user.id)
.result;
}
}
}
})();

View File

@ -72,6 +72,7 @@
var deferred = $q.defer();
spyOn(keystone, 'createUser').and.returnValue(deferred.promise);
spyOn(toast, 'add').and.callFake(angular.noop);
spyOn(keystone, 'grantRole');
var handler = jasmine.createSpyObj('handler', ['success']);
deferred.resolve({data: {name: 'saved', id: '12345'}});