|
1 | 1 | //! This piece of the project exposes a GraphQL endpoint that allows one to access DAILP data in a federated manner with specific queries. |
2 | 2 |
|
| 3 | +use aws_sdk_cognitoidentityprovider::Client; |
3 | 4 | use dailp::{ |
4 | 5 | async_graphql::InputType, |
5 | 6 | auth::{AuthGuard, GroupGuard, NotGroupGuard, UserGroup, UserInfo}, |
6 | 7 | collection, |
7 | 8 | comment::{CommentParent, CommentUpdate, DeleteCommentInput, PostCommentInput}, |
8 | 9 | page::{NewPageInput, Page}, |
9 | 10 | slugify_ltree, |
10 | | - user::{User, UserUpdate}, |
| 11 | + user::{User, UserId, UserUpdate}, |
11 | 12 | AnnotatedForm, AnnotatedSeg, AttachAudioToDocumentInput, AttachAudioToWordInput, |
12 | 13 | CollectionChapter, Contributor, ContributorRole, CreateEditedCollectionInput, |
13 | 14 | CurateDocumentAudioInput, CurateWordAudioInput, Date, DeleteContributorAttribution, |
@@ -643,6 +644,29 @@ impl Mutation { |
643 | 644 | .ok_or_else(|| anyhow::format_err!("Failed to load document"))?) |
644 | 645 | } |
645 | 646 |
|
| 647 | + // Deletes a user |
| 648 | + #[graphql(guard = "AuthGuard")] |
| 649 | + async fn delete_user(&self, context: &Context<'_>, user_id: Uuid) -> FieldResult<UserId> { |
| 650 | + // let cognito = context.data::<aws_sdk_cognitoidentityprovider::Client>()?; |
| 651 | + // let user_pool_id = std::env::var("DAILP_USER_POOL") |
| 652 | + // .map_err(|_| anyhow::format_err!("DAILP_USER_POOL not set"))?; |
| 653 | + |
| 654 | + // let identity_result = cognito |
| 655 | + // .admin_delete_user() |
| 656 | + // .user_pool_id(std::env::var("DAILP_USER_POOL")) |
| 657 | + // .username(user_id.to_string()) |
| 658 | + // .send() |
| 659 | + // .await |
| 660 | + // .map_err(|e| anyhow::format_err!("Failed to delete user: {}", e))?; |
| 661 | + |
| 662 | + // log::info!("admin_delete_user result: {:?}", identity_result); |
| 663 | + Ok(context |
| 664 | + .data::<DataLoader<Database>>()? |
| 665 | + .loader() |
| 666 | + .delete_user(&user_id) |
| 667 | + .await?) |
| 668 | + } |
| 669 | + |
646 | 670 | /// Decide if a piece of word audio should be included in edited collection |
647 | 671 | #[graphql(guard = "GroupGuard::new(UserGroup::Editors)")] |
648 | 672 | async fn curate_word_audio( |
|
0 commit comments