mirror of https://github.com/LemmyNet/lemmy.git
* Adding a captcha rate limit. Fixes #1755 * Changing to post rate limit.try_docker_latest
parent
97b8b9c255
commit
e765b42d46
|
@ -491,7 +491,10 @@ impl ChatServer {
|
||||||
} else {
|
} else {
|
||||||
let user_operation = UserOperation::from_str(op)?;
|
let user_operation = UserOperation::from_str(op)?;
|
||||||
let fut = (message_handler)(context, msg.id, user_operation.clone(), data);
|
let fut = (message_handler)(context, msg.id, user_operation.clone(), data);
|
||||||
rate_limiter.message().wrap(ip, fut).await
|
match user_operation {
|
||||||
|
UserOperation::GetCaptcha => rate_limiter.post().wrap(ip, fut).await,
|
||||||
|
_ => rate_limiter.message().wrap(ip, fut).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,12 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
.wrap(rate_limit.register())
|
.wrap(rate_limit.register())
|
||||||
.route(web::post().to(route_post_crud::<Register>)),
|
.route(web::post().to(route_post_crud::<Register>)),
|
||||||
)
|
)
|
||||||
|
.service(
|
||||||
|
// Handle captcha separately
|
||||||
|
web::resource("/user/get_captcha")
|
||||||
|
.wrap(rate_limit.post())
|
||||||
|
.route(web::get().to(route_get::<GetCaptcha>)),
|
||||||
|
)
|
||||||
// User actions
|
// User actions
|
||||||
.service(
|
.service(
|
||||||
web::scope("/user")
|
web::scope("/user")
|
||||||
|
@ -178,7 +184,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
.route("/block", web::post().to(route_post::<BlockPerson>))
|
.route("/block", web::post().to(route_post::<BlockPerson>))
|
||||||
// Account actions. I don't like that they're in /user maybe /accounts
|
// Account actions. I don't like that they're in /user maybe /accounts
|
||||||
.route("/login", web::post().to(route_post::<Login>))
|
.route("/login", web::post().to(route_post::<Login>))
|
||||||
.route("/get_captcha", web::get().to(route_get::<GetCaptcha>))
|
|
||||||
.route(
|
.route(
|
||||||
"/delete_account",
|
"/delete_account",
|
||||||
web::post().to(route_post_crud::<DeleteAccount>),
|
web::post().to(route_post_crud::<DeleteAccount>),
|
||||||
|
|
Loading…
Reference in New Issue