Throw PermissionDeniedException for denied user name change requests
When trying to change the user name although the used realm does not permit this, a NameAlreadyUsedException has been thrown. We replace this exception by the more appropriate PermissionDeniedException. Change-Id: I4cbf6aa6100ac93411cafbb3cb33b92475ccba9a
This commit is contained in:
parent
55364017da
commit
559cbe2d51
@ -20,8 +20,8 @@ import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.common.errors.ContactInformationStoreException;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.common.errors.InvalidSshKeyException;
|
||||
import com.google.gerrit.common.errors.NameAlreadyUsedException;
|
||||
import com.google.gerrit.common.errors.NoSuchEntityException;
|
||||
import com.google.gerrit.common.errors.PermissionDeniedException;
|
||||
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@ -187,7 +187,8 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
if (realm.allowsEdit(Account.FieldName.USER_NAME)) {
|
||||
Handler.wrap(changeUserNameFactory.create(newName)).to(callback);
|
||||
} else {
|
||||
callback.onFailure(new NameAlreadyUsedException());
|
||||
callback.onFailure(new PermissionDeniedException("Not allowed to change"
|
||||
+ " username"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user