Fix banning of remote user (fixes #4169) (#4171)

This commit is contained in:
Nutomic 2023-11-21 14:44:55 +01:00 committed by GitHub
parent 82b30b5467
commit 62357f4444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);