@@ -50,7 +50,7 @@ class AccountSpaceNB {
5050 //const root_account = _.find(system_store.data.accounts, account => account.name.unwrap() === requesting_account.name.unwrap());
5151 const requesting_account = system_store . get_account_by_email ( account_sdk . requesting_account . email ) ;
5252 account_util . _check_if_requesting_account_is_root_account ( action , requesting_account ,
53- { username : params . username , iam_path : params . iam_path } ) ;
53+ { username : params . username , path : params . iam_path } ) ;
5454 account_util . _check_username_already_exists ( action , params , requesting_account ) ;
5555 const iam_arn = iam_utils . create_arn_for_user ( requesting_account . _id . toString ( ) , params . username , params . iam_path ) ;
5656 const account_name = new SensitiveString ( `${ params . username } :${ requesting_account . name . unwrap ( ) } ` ) ;
@@ -64,7 +64,9 @@ class AccountSpaceNB {
6464 owner : requesting_account . _id . toString ( ) ,
6565 is_iam : true ,
6666 iam_arn : iam_arn ,
67+ iam_path : params . iam_path ,
6768 role : 'iam_user' ,
69+
6870 // TODO: default_resource remove
6971 default_resource : 'noobaa-default-backing-store' ,
7072 } ,
@@ -82,7 +84,7 @@ class AccountSpaceNB {
8284 username : params . username ,
8385 user_id : iam_account . id ,
8486 arn : iam_arn ,
85- create_date : iam_account . creation_date ,
87+ create_date : iam_account . create_date ,
8688 } ;
8789
8890 }
@@ -106,8 +108,8 @@ class AccountSpaceNB {
106108 iam_path : requested_account . iam_path || IAM_DEFAULT_PATH ,
107109 username : requested_account . name . unwrap ( ) . split ( IAM_SPLIT_CHARACTERS ) [ 0 ] ,
108110 arn : requested_account . iam_arn ,
111+ create_date : new Date ( requested_account . last_update ) ,
109112 // TODO: Dates missing : GAP
110- create_date : new Date ( ) ,
111113 password_last_used : new Date ( ) ,
112114 } ;
113115 return reply ;
@@ -123,6 +125,7 @@ class AccountSpaceNB {
123125 const requested_account = system_store . get_account_by_email ( account_name ) ;
124126 let new_iam_path = requested_account . iam_path ;
125127 let new_user_name = requested_account . name . unwrap ( ) ;
128+ account_util . _check_username_already_exists ( action , { username : params . new_username } , requesting_account ) ;
126129 const root_account = _ . find ( system_store . data . accounts , account => account . name . unwrap ( ) === requesting_account . name . unwrap ( ) ) ;
127130 account_util . _check_if_requested_account_is_root_account_or_IAM_user ( action , requesting_account , requested_account ) ;
128131 account_util . _check_if_requested_is_owned_by_root_account ( action , root_account , requested_account ) ;
@@ -136,7 +139,7 @@ class AccountSpaceNB {
136139 iam_arn : iam_arn ,
137140 } ;
138141 // CORE CHANGES PENDING - START
139- system_store . make_changes ( {
142+ await system_store . make_changes ( {
140143 update : {
141144 accounts : [ {
142145 _id : requested_account . _id ,
@@ -149,8 +152,8 @@ class AccountSpaceNB {
149152 // TODO : Send Event
150153 return {
151154 // TODO: IAM path needs to be saved
152- iam_path : requested_account . iam_path || IAM_DEFAULT_PATH ,
153- username : requested_account . name . unwrap ( ) ,
155+ iam_path : new_iam_path || IAM_DEFAULT_PATH ,
156+ username : new_user_name ,
154157 user_id : requested_account . _id . toString ( ) ,
155158 arn : iam_arn
156159 } ;
@@ -203,7 +206,8 @@ class AccountSpaceNB {
203206 iam_path : iam_user . iam_path || IAM_DEFAULT_PATH ,
204207 username : iam_user . name . unwrap ( ) . split ( IAM_SPLIT_CHARACTERS ) [ 0 ] ,
205208 arn : iam_user . iam_arn ,
206- create_date : iam_user . creation_date ,
209+ create_date : new Date ( iam_user . last_update ) ,
210+ // TODO: Miising password_last_used
207211 password_last_used : Date . now ( ) , // GAP
208212 } ;
209213 return member ;
0 commit comments