This commit is contained in:
Mateusz Gruszczyński committed 2026-11-01 00:25:29 +01:00
1 parent 99a5700caa
commit b752f52fd8
22 files changed
+313 -138

No files matched your search

+1 -1
View File
@@ -233,7 +233,7 @@ fn escape_filter(value: &str) -> String {
b')' => result.push_str("\\29"),
b'\\' => result.push_str("\\5c"),
0 => result.push_str("\\00"),
value if value < 0x20 || value >= 0x7f => result.push_str(&format!("\\{value:02x}")),
value if !(0x20..0x7f).contains(&value) => result.push_str(&format!("\\{value:02x}")),
value => result.push(value as char),
}
}
+13 -15
View File
@@ -480,7 +480,7 @@ pub async fn register(
.ok_or_else(|| AuthError::internal("Failed to create the account."))?;
let mut confirmation_token = None;
if state.smtp.is_some() {
if let Some(smtp) = &state.smtp {
let token = random_confirmation_token();
if state.account_confirmation_required {
let expires = (Utc::now() + Duration::hours(24)).to_rfc3339();
@@ -506,9 +506,7 @@ pub async fn register(
tx.commit().await.map_err(AuthError::database)?;
confirmation_token = Some(token.as_str());
}
if let Err(error) =
send_registration_email(state.smtp.as_ref().unwrap(), &user, confirmation_token).await
{
if let Err(error) = send_registration_email(smtp, &user, confirmation_token).await {
if state.account_confirmation_required {
if let Err(delete_error) =
sqlx::query(queries::get(state.db.kind(), queries::AUTH_DELETE_USER))
@@ -638,16 +636,16 @@ pub async fn resend_confirmation(
.fetch_optional(state.db.pool())
.await
.map_err(AuthError::database)?;
if let Some(value) = last_created {
if let Ok(created) = chrono::DateTime::parse_from_rfc3339(&value) {
let available = created.with_timezone(&Utc) + Duration::minutes(10);
if available > Utc::now() {
let seconds = (available - Utc::now()).num_seconds().max(1);
return Err(AuthError::bad_request(&format!(
"A new confirmation e-mail can be sent in {} minute(s).",
(seconds + 59) / 60
)));
}
if let Some(value) = last_created
&& let Ok(created) = chrono::DateTime::parse_from_rfc3339(&value)
{
let available = created.with_timezone(&Utc) + Duration::minutes(10);
if available > Utc::now() {
let seconds = (available - Utc::now()).num_seconds().max(1);
return Err(AuthError::bad_request(&format!(
"A new confirmation e-mail can be sent in {} minute(s).",
(seconds + 59) / 60
)));
}
}
sqlx::query(queries::get(
@@ -1345,7 +1343,7 @@ pub async fn resources(
let page = query.page.max(1);
let per_page = normalized_per_page(query.per_page);
let total = items.len();
let total_pages = ((total + per_page - 1) / per_page).max(1);
let total_pages = total.div_ceil(per_page).max(1);
let page = page.min(total_pages);
let start = (page - 1) * per_page;
let items = items