Skip to content

Commit

Permalink
Revert "feat: re-added captcha checks (#3249)" (#3288)
Browse files Browse the repository at this point in the history
This reverts commit 8a086c8.
  • Loading branch information
dessalines committed Jun 23, 2023
1 parent dce79b8 commit 1f1c0ad
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 300 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async-trait = { workspace = true }
captcha = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
chrono = { workspace = true }

[dev-dependencies]
serial_test = { workspace = true }
Expand Down
16 changes: 0 additions & 16 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use actix_web::web::Data;
use captcha::Captcha;
use lemmy_api_common::{context::LemmyContext, utils::local_site_to_slur_regex};
use lemmy_db_schema::source::local_site::LocalSite;
use lemmy_utils::{error::LemmyError, utils::slurs::check_slurs};
Expand All @@ -21,21 +20,6 @@ pub trait Perform {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError>;
}

/// Converts the captcha to a base64 encoded wav audio file
pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> String {
let letters = captcha.as_wav();

let mut concat_letters: Vec<u8> = Vec::new();

for letter in letters {
let bytes = letter.unwrap_or_default();
concat_letters.extend(bytes);
}

// Convert to base64
base64::encode(concat_letters)
}

/// Check size of report and remove whitespace
pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> Result<(), LemmyError> {
let slur_regex = &local_site_to_slur_regex(local_site);
Expand Down
53 changes: 0 additions & 53 deletions crates/api/src/local_user/get_captcha.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/api/src/local_user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod ban_person;
mod block;
mod change_password;
mod change_password_after_reset;
mod get_captcha;
mod list_banned;
mod login;
mod notifications;
Expand Down
1 change: 0 additions & 1 deletion crates/api_crud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ tracing = { workspace = true }
url = { workspace = true }
async-trait = { workspace = true }
webmention = "0.4.0"
chrono = { worspace = true }
18 changes: 0 additions & 18 deletions crates/api_crud/src/user/create.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::PerformCrud;
use activitypub_federation::http_signatures::generate_actor_keypair;
use actix_web::web::Data;
use chrono::NaiveDateTime;
use lemmy_api_common::{
context::LemmyContext,
person::{LoginResponse, Register},
Expand All @@ -20,7 +19,6 @@ use lemmy_api_common::{
use lemmy_db_schema::{
aggregates::structs::PersonAggregates,
source::{
captcha_answer::CaptchaAnswer,
local_user::{LocalUser, LocalUserInsertForm},
person::{Person, PersonInsertForm},
registration_application::{RegistrationApplication, RegistrationApplicationInsertForm},
Expand Down Expand Up @@ -73,22 +71,6 @@ impl PerformCrud for Register {
return Err(LemmyError::from_message("passwords_dont_match"));
}

if local_site.site_setup && local_site.captcha_enabled {
let check = CaptchaAnswer::check_captcha(
context.pool(),
CaptchaAnswer {
uuid: data.captcha_uuid.clone().unwrap_or_default(),
answer: data.captcha_answer.clone().unwrap_or_default(),
// not used when checking
expires: NaiveDateTime::MIN,
},
)
.await?;
if !check {
return Err(LemmyError::from_message("captcha_incorrect"));
}
}

let slur_regex = local_site_to_slur_regex(&local_site);
check_slurs(&data.username, &slur_regex)?;
check_slurs_opt(&data.answer, &slur_regex)?;
Expand Down
26 changes: 20 additions & 6 deletions crates/db_schema/src/diesel_ltree.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
--- schema.rs 2023-06-21 22:25:50.252384233 +0100
+++ "schema copy.rs" 2023-06-21 22:26:50.452378651 +0100
@@ -6,10 +6,6 @@
pub struct ListingTypeEnum;
diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs
index 255c6422..f2ccf5e2 100644
--- a/crates/db_schema/src/schema.rs
+++ b/crates/db_schema/src/schema.rs
@@ -2,16 +2,12 @@

pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "listing_type_enum"))]
pub struct ListingTypeEnum;

- #[derive(diesel::sql_types::SqlType)]
- #[diesel(postgres_type(name = "ltree"))]
- pub struct Ltree;
-
- #[derive(diesel::sql_types::SqlType)]
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "registration_mode_enum"))]
pub struct RegistrationModeEnum;

@@ -78,7 +74,7 @@
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "sort_type_enum"))]
@@ -67,13 +63,13 @@ diesel::table! {
when_ -> Timestamp,
}
}

diesel::table! {
use diesel::sql_types::*;
Expand All @@ -20,3 +31,6 @@

comment (id) {
id -> Int4,
creator_id -> Int4,
post_id -> Int4,
content -> Text,
164 changes: 0 additions & 164 deletions crates/db_schema/src/impls/captcha_answer.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/db_schema/src/impls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod activity;
pub mod actor_language;
pub mod captcha_answer;
pub mod comment;
pub mod comment_reply;
pub mod comment_report;
Expand Down
9 changes: 0 additions & 9 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ diesel::table! {
}
}

diesel::table! {
captcha_answer (uuid) {
uuid -> Text,
answer -> Text,
expires -> Timestamp,
}
}

diesel::table! {
use diesel::sql_types::{Bool, Int4, Nullable, Text, Timestamp, Varchar};
use diesel_ltree::sql_types::Ltree;
Expand Down Expand Up @@ -924,7 +916,6 @@ diesel::allow_tables_to_appear_in_same_query!(
admin_purge_community,
admin_purge_person,
admin_purge_post,
captcha_answer,
comment,
comment_aggregates,
comment_like,
Expand Down

1 comment on commit 1f1c0ad

@BrenoMartinsDeOliveiraVasconcelos

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo, why y'all removed captcha again??

Please sign in to comment.