Removes a user from the profile context using the admin client.
(
cx: &ProfileContext,
RemoveArgs { email }: RemoveArgs<'_>,
)
| 86 | |
| 87 | /// Removes a user from the profile context using the admin client. |
| 88 | pub async fn remove( |
| 89 | cx: &ProfileContext, |
| 90 | RemoveArgs { email }: RemoveArgs<'_>, |
| 91 | ) -> Result<(), Error> { |
| 92 | let loading_spinner = cx.output_formatter().loading_spinner("Removing user..."); |
| 93 | |
| 94 | let users = cx.admin_client().list_users().await?; |
| 95 | let user = users |
| 96 | .into_iter() |
| 97 | .find(|x| x.email == email) |
| 98 | .expect("email not found."); |
| 99 | |
| 100 | cx.admin_client() |
| 101 | .remove_user(RemoveUserRequest { user_id: user.id }) |
| 102 | .await?; |
| 103 | |
| 104 | loading_spinner.finish_with_message(format!("User {} removed.", email)); |
| 105 | Ok(()) |
| 106 | } |
no test coverage detected