Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c700d65b34
|
|||
|
8bf2917eb7
|
|||
|
fc8dc805a9
|
|||
|
5b6dd0c4f7
|
|||
|
b29a095a38
|
|||
|
85621d9364
|
|||
|
5baa73d272
|
|||
|
ff6aa10d91
|
|||
|
598af596c7
|
|||
|
9f576d7509
|
|||
|
2216d7da58
|
|||
|
d4fdc2f468
|
|||
|
dcb3dc60a4
|
|||
|
b38e6110d2
|
@@ -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: "contact", tracing::Level::ERROR, "SMTP Error details: {}", format!("{value:?}"));
|
tracing::event!(target: "backend::contact", tracing::Level::ERROR, "SMTP Error details: {}", format!("{value:?}"));
|
||||||
Self::OtherError(value.to_string())
|
Self::OtherError(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ 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()
|
||||||
{
|
{
|
||||||
@@ -198,6 +197,7 @@ 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: "contact", tracing::Level::DEBUG, "Email to be sent: {}", format!("{email:?}"));
|
tracing::event!(target: "backend::contact", tracing::Level::DEBUG, "Email to be sent: {}", format!("{email:?}"));
|
||||||
Ok(email)
|
Ok(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -84,10 +84,12 @@ 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!(
|
||||||
!cfg!(test) || !frontend_url.is_empty(),
|
!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