@@ -748,8 +748,6 @@ struct GetOrgUserData {
748
748
include_groups : Option < bool > ,
749
749
}
750
750
751
- // includeCollections
752
- // includeGroups
753
751
#[ get( "/organizations/<org_id>/users?<data..>" ) ]
754
752
async fn get_org_users (
755
753
data : GetOrgUserData ,
@@ -1229,21 +1227,33 @@ async fn _confirm_invite(
1229
1227
save_result
1230
1228
}
1231
1229
1232
- #[ get( "/organizations/<org_id>/users/<org_user_id>" ) ]
1233
- async fn get_user ( org_id : String , org_user_id : String , _headers : AdminHeaders , mut conn : DbConn ) -> JsonResult {
1230
+ #[ get( "/organizations/<org_id>/users/<org_user_id>?<data..>" ) ]
1231
+ async fn get_user (
1232
+ org_id : String ,
1233
+ org_user_id : String ,
1234
+ data : GetOrgUserData ,
1235
+ _headers : AdminHeaders ,
1236
+ mut conn : DbConn ,
1237
+ ) -> JsonResult {
1234
1238
let user = match UserOrganization :: find_by_uuid_and_org ( & org_user_id, & org_id, & mut conn) . await {
1235
1239
Some ( user) => user,
1236
1240
None => err ! ( "The specified user isn't a member of the organization" ) ,
1237
1241
} ;
1238
1242
1239
- Ok ( Json ( user. to_json_details ( & mut conn) . await ) )
1243
+ // In this case, when groups are requested we also need to include collections.
1244
+ // Else these will not be shown in the interface, and could lead to missing collections when saved.
1245
+ let include_groups = data. include_groups . unwrap_or ( false ) ;
1246
+ Ok ( Json (
1247
+ user. to_json_user_details ( data. include_collections . unwrap_or ( include_groups) , include_groups, & mut conn) . await ,
1248
+ ) )
1240
1249
}
1241
1250
1242
1251
#[ derive( Deserialize ) ]
1243
1252
#[ allow( non_snake_case) ]
1244
1253
struct EditUserData {
1245
1254
Type : NumberOrString ,
1246
1255
Collections : Option < Vec < CollectionData > > ,
1256
+ Groups : Option < Vec < String > > ,
1247
1257
AccessAll : bool ,
1248
1258
}
1249
1259
@@ -1342,6 +1352,13 @@ async fn edit_user(
1342
1352
}
1343
1353
}
1344
1354
1355
+ GroupUser :: delete_all_by_user ( & user_to_edit. uuid , & mut conn) . await ?;
1356
+
1357
+ for group in data. Groups . iter ( ) . flatten ( ) {
1358
+ let mut group_entry = GroupUser :: new ( String :: from ( group) , user_to_edit. uuid . clone ( ) ) ;
1359
+ group_entry. save ( & mut conn) . await ?;
1360
+ }
1361
+
1345
1362
log_event (
1346
1363
EventType :: OrganizationUserUpdated as i32 ,
1347
1364
& user_to_edit. uuid ,
0 commit comments