From 62357f4444ac7c33377dff939fa9b3f9d34037a7 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Tue, 21 Nov 2023 14:44:55 +0100 Subject: [PATCH] Fix banning of remote user (fixes #4169) (#4171) --- crates/api/src/local_user/ban_person.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index d7c47e619..63ecebed5 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -46,11 +46,11 @@ pub async fn ban_from_site( .await .with_lemmy_type(LemmyErrorType::CouldntUpdateUser)?; - let local_user_id = LocalUserView::read_person(&mut context.pool(), data.person_id) - .await? - .local_user - .id; - LoginToken::invalidate_all(&mut context.pool(), local_user_id).await?; + // if its a local user, invalidate logins + let local_user = LocalUserView::read_person(&mut context.pool(), data.person_id).await; + if let Ok(local_user) = local_user { + LoginToken::invalidate_all(&mut context.pool(), local_user.local_user.id).await?; + } // Remove their data if that's desired let remove_data = data.remove_data.unwrap_or(false);