@@ -1227,12 +1227,11 @@ async function get_user(req) {
12271227async function update_user ( req ) {
12281228
12291229 const action = IAM_ACTIONS . UPDATE_USER ;
1230- const requesting_account = system_store . get_account_by_email ( req . account . email ) ;
1230+ const requesting_account = req . account ;
12311231 const old_username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
12321232 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account ,
12331233 { username : req . rpc_params . username , iam_path : req . rpc_params . new_iam_path } ) ;
1234- account_util . _check_if_account_exists ( action , old_username ) ;
1235- const requested_account = system_store . get_account_by_email ( old_username ) ;
1234+ const requested_account = account_util . _check_if_account_exists ( action , old_username ) ;
12361235 let iam_path = requested_account . iam_path ;
12371236 let user_name = account_util . get_iam_username ( requested_account . name . unwrap ( ) ) ;
12381237 // Change to complete user name
@@ -1272,8 +1271,7 @@ async function delete_user(req) {
12721271 const requesting_account = req . account ;
12731272 const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
12741273 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1275- account_util . _check_if_account_exists ( action , username ) ;
1276- const requested_account = system_store . get_account_by_email ( username ) ;
1274+ const requested_account = account_util . _check_if_account_exists ( action , username ) ;
12771275 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
12781276 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
12791277 account_util . _check_if_user_does_not_have_resources_before_deletion ( action , requested_account ) ;
@@ -1425,12 +1423,11 @@ async function delete_access_key(req) {
14251423async function tag_user ( req ) {
14261424 const action = IAM_ACTIONS . TAG_USER ;
14271425 const requesting_account = req . account ;
1428- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1426+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
14291427
14301428 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1431- account_util . _check_if_account_exists ( action , username ) ;
1429+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
14321430
1433- const requested_account = system_store . get_account_by_email ( username ) ;
14341431 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
14351432 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
14361433
@@ -1467,12 +1464,10 @@ async function tag_user(req) {
14671464async function untag_user ( req ) {
14681465 const action = IAM_ACTIONS . UNTAG_USER ;
14691466 const requesting_account = req . account ;
1470- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1467+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
14711468
14721469 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1473- account_util . _check_if_account_exists ( action , username ) ;
1474-
1475- const requested_account = system_store . get_account_by_email ( username ) ;
1470+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
14761471 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
14771472 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
14781473
@@ -1496,12 +1491,10 @@ async function untag_user(req) {
14961491async function list_user_tags ( req ) {
14971492 const action = IAM_ACTIONS . LIST_USER_TAGS ;
14981493 const requesting_account = req . account ;
1499- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1494+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
15001495
15011496 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1502- account_util . _check_if_account_exists ( action , username ) ;
1503-
1504- const requested_account = system_store . get_account_by_email ( username ) ;
1497+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
15051498 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
15061499 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
15071500
0 commit comments