Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
7fe75bb559
|
|||
|
b6d7c50a38
|
|||
|
002ff9a1c5
|
|||
|
6bc14c7429
|
|||
|
03592c1e83
|
|||
|
6199e73e59
|
|||
|
3c65e1d83d
|
|||
|
7294cd7651
|
|||
|
123c0d17ed
|
|||
|
7e074888a6
|
|||
|
215ac75721
|
|||
|
4d3432e92f
|
|||
|
e3aaf05838
|
|||
|
bb4e230c0d
|
@@ -54,7 +54,7 @@ impl Error for ContactError {}
|
|||||||
/// issues beyond the client's control.
|
/// issues beyond the client's control.
|
||||||
impl From<lettre::transport::smtp::Error> for ContactError {
|
impl From<lettre::transport::smtp::Error> for ContactError {
|
||||||
fn from(value: lettre::transport::smtp::Error) -> Self {
|
fn from(value: lettre::transport::smtp::Error) -> Self {
|
||||||
tracing::event!(target: "backend::contact", tracing::Level::ERROR, "SMTP Error details: {}", format!("{value:?}"));
|
tracing::event!(target: "contact", tracing::Level::ERROR, "SMTP Error details: {}", format!("{value:?}"));
|
||||||
Self::OtherError(value.to_string())
|
Self::OtherError(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ impl ContactApi {
|
|||||||
remote_addr: Option<poem::web::Data<&poem::web::RemoteAddr>>,
|
remote_addr: Option<poem::web::Data<&poem::web::RemoteAddr>>,
|
||||||
) -> ContactApiResponse {
|
) -> ContactApiResponse {
|
||||||
let mut body = body.0;
|
let mut body = body.0;
|
||||||
|
body.sanitize();
|
||||||
if let Some(ref honeypot) = body.honeypot
|
if let Some(ref honeypot) = body.honeypot
|
||||||
&& !honeypot.trim().is_empty()
|
&& !honeypot.trim().is_empty()
|
||||||
{
|
{
|
||||||
@@ -197,7 +198,6 @@ impl ContactApi {
|
|||||||
);
|
);
|
||||||
return ContactApiResponse::Ok(ContactResponse::honeypot_response().into());
|
return ContactApiResponse::Ok(ContactResponse::honeypot_response().into());
|
||||||
}
|
}
|
||||||
body.sanitize();
|
|
||||||
if let Err(e) = body.validate() {
|
if let Err(e) = body.validate() {
|
||||||
return ContactApiResponse::BadRequest(
|
return ContactApiResponse::BadRequest(
|
||||||
<validator::ValidationErrors as std::convert::Into<ContactResponse>>::into(e)
|
<validator::ValidationErrors as std::convert::Into<ContactResponse>>::into(e)
|
||||||
@@ -251,7 +251,7 @@ impl ContactApi {
|
|||||||
.subject(format!("Contact Form: {}", request.name))
|
.subject(format!("Contact Form: {}", request.name))
|
||||||
.header(ContentType::TEXT_PLAIN)
|
.header(ContentType::TEXT_PLAIN)
|
||||||
.body(email_body)?;
|
.body(email_body)?;
|
||||||
tracing::event!(target: "backend::contact", tracing::Level::DEBUG, "Email to be sent: {}", format!("{email:?}"));
|
tracing::event!(target: "contact", tracing::Level::DEBUG, "Email to be sent: {}", format!("{email:?}"));
|
||||||
Ok(email)
|
Ok(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -84,12 +84,10 @@ impl From<Application> for RunnableApplication {
|
|||||||
let cors = if value.settings.debug {
|
let cors = if value.settings.debug {
|
||||||
Cors::new()
|
Cors::new()
|
||||||
} else {
|
} else {
|
||||||
if !cfg!(test) {
|
|
||||||
assert!(
|
assert!(
|
||||||
!frontend_url.is_empty(),
|
!cfg!(test) || !frontend_url.is_empty(),
|
||||||
"CORS: frontend_url must be configured in production"
|
"CORS: frontend_url must be configured in production"
|
||||||
);
|
);
|
||||||
}
|
|
||||||
Cors::new().allow_origin(frontend_url)
|
Cors::new().allow_origin(frontend_url)
|
||||||
};
|
};
|
||||||
let app = value
|
let app = value
|
||||||
|
|||||||
Reference in New Issue
Block a user