Skip to content

Commit b0c05ca

Browse files
committed
CR changes
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent 0098e6d commit b0c05ca

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/server/system_services/account_server.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,14 @@ async function update_user(req) {
12341234
let iam_path = requested_account.iam_path;
12351235
let user_name = account_util.get_iam_username(requested_account.name.unwrap());
12361236
// Change to complete user name
1237-
const email_new_username = account_util.get_account_name_from_username(req.rpc_params.new_username, requesting_account._id.toString());
1238-
const is_username_update = req.rpc_params.new_username !== undefined && req.rpc_params.new_username !== req.rpc_params.username;
1239-
if (is_username_update) account_util._check_username_already_exists(action, email_new_username, req.rpc_params.new_username);
1237+
const is_username_update = req.rpc_params.new_username !== undefined &&
1238+
req.rpc_params.new_username !== req.rpc_params.username;
1239+
if (is_username_update) {
1240+
const email_new_username = account_util.get_account_name_from_username(
1241+
req.rpc_params.new_username,
1242+
requesting_account._id.toString());
1243+
account_util._check_username_already_exists(action, email_new_username, req.rpc_params.new_username);
1244+
}
12401245
account_util._check_if_requested_account_is_root_account_or_IAM_user(action, requesting_account, requested_account);
12411246
account_util._check_if_requested_is_owned_by_root_account(action, requesting_account, requested_account);
12421247
if (req.rpc_params.new_iam_path) iam_path = req.rpc_params.new_iam_path;

src/test/integration_tests/api/iam/test_iam_advanced_integration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ mocha.describe('IAM advanced integration tests', async function() {
180180
};
181181
const command = new UpdateUserCommand(input);
182182
await iam_account.send(command);
183-
assert.fail('create user with existing username (lower case) - should throw an error');
183+
assert.fail('update user with existing username (lower case) - should throw an error');
184184
} catch (err) {
185185
const err_code = err.Error.Code;
186186
assert.equal(err_code, IamError.EntityAlreadyExists.code);
@@ -195,7 +195,7 @@ mocha.describe('IAM advanced integration tests', async function() {
195195
};
196196
const command = new UpdateUserCommand(input);
197197
await iam_account.send(command);
198-
assert.fail('create user with existing username (upper case) - should throw an error');
198+
assert.fail('update user with existing username (upper case) - should throw an error');
199199
} catch (err) {
200200
const err_code = err.Error.Code;
201201
assert.equal(err_code, IamError.EntityAlreadyExists.code);

0 commit comments

Comments
 (0)