@@ -1225,12 +1225,11 @@ async function get_user(req) {
12251225async function update_user ( req ) {
12261226
12271227 const action = IAM_ACTIONS . UPDATE_USER ;
1228- const requesting_account = system_store . get_account_by_email ( req . account . email ) ;
1228+ const requesting_account = req . account ;
12291229 const old_username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
12301230 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account ,
12311231 { username : req . rpc_params . username , iam_path : req . rpc_params . new_iam_path } ) ;
1232- account_util . _check_if_account_exists ( action , old_username ) ;
1233- const requested_account = system_store . get_account_by_email ( old_username ) ;
1232+ const requested_account = account_util . _check_if_account_exists ( action , old_username ) ;
12341233 let iam_path = requested_account . iam_path ;
12351234 let user_name = account_util . get_iam_username ( requested_account . name . unwrap ( ) ) ;
12361235 // Change to complete user name
@@ -1270,8 +1269,7 @@ async function delete_user(req) {
12701269 const requesting_account = req . account ;
12711270 const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
12721271 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1273- account_util . _check_if_account_exists ( action , username ) ;
1274- const requested_account = system_store . get_account_by_email ( username ) ;
1272+ const requested_account = account_util . _check_if_account_exists ( action , username ) ;
12751273 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
12761274 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
12771275 account_util . _check_if_user_does_not_have_resources_before_deletion ( action , requested_account ) ;
@@ -1423,12 +1421,11 @@ async function delete_access_key(req) {
14231421async function tag_user ( req ) {
14241422 const action = IAM_ACTIONS . TAG_USER ;
14251423 const requesting_account = req . account ;
1426- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1424+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
14271425
14281426 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1429- account_util . _check_if_account_exists ( action , username ) ;
1427+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
14301428
1431- const requested_account = system_store . get_account_by_email ( username ) ;
14321429 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
14331430 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
14341431
@@ -1465,12 +1462,10 @@ async function tag_user(req) {
14651462async function untag_user ( req ) {
14661463 const action = IAM_ACTIONS . UNTAG_USER ;
14671464 const requesting_account = req . account ;
1468- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1465+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
14691466
14701467 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1471- account_util . _check_if_account_exists ( action , username ) ;
1472-
1473- const requested_account = system_store . get_account_by_email ( username ) ;
1468+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
14741469 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
14751470 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
14761471
@@ -1494,12 +1489,10 @@ async function untag_user(req) {
14941489async function list_user_tags ( req ) {
14951490 const action = IAM_ACTIONS . LIST_USER_TAGS ;
14961491 const requesting_account = req . account ;
1497- const username = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
1492+ const email_wrapped = account_util . get_account_name_from_username ( req . rpc_params . username , requesting_account . _id . toString ( ) ) ;
14981493
14991494 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account , { username : req . rpc_params . username } ) ;
1500- account_util . _check_if_account_exists ( action , username ) ;
1501-
1502- const requested_account = system_store . get_account_by_email ( username ) ;
1495+ const requested_account = account_util . _check_if_account_exists ( action , email_wrapped ) ;
15031496 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
15041497 account_util . _check_if_requested_is_owned_by_root_account ( action , requesting_account , requested_account ) ;
15051498
0 commit comments