Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-22 05:10:29 +01:00
Use constant for the "inaccessible" error message
Dieser Commit ist enthalten in:
Ursprung
4b6a574ee0
Commit
aa5cc642e1
1 geänderte Dateien mit 12 neuen und 10 gelöschten Zeilen
|
@ -13,6 +13,8 @@ use crate::{
|
||||||
CONFIG,
|
CONFIG,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SEND_INACCESSIBLE_MSG: &str = "Send does not exist or is no longer available";
|
||||||
|
|
||||||
pub fn routes() -> Vec<rocket::Route> {
|
pub fn routes() -> Vec<rocket::Route> {
|
||||||
routes![
|
routes![
|
||||||
post_send,
|
post_send,
|
||||||
|
@ -228,27 +230,27 @@ pub struct SendAccessData {
|
||||||
fn post_access(access_id: String, data: JsonUpcase<SendAccessData>, conn: DbConn) -> JsonResult {
|
fn post_access(access_id: String, data: JsonUpcase<SendAccessData>, conn: DbConn) -> JsonResult {
|
||||||
let mut send = match Send::find_by_access_id(&access_id, &conn) {
|
let mut send = match Send::find_by_access_id(&access_id, &conn) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => err_code!("Send does not exist or is no longer available", 404),
|
None => err_code!(SEND_INACCESSIBLE_MSG, 404),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(max_access_count) = send.max_access_count {
|
if let Some(max_access_count) = send.max_access_count {
|
||||||
if send.access_count >= max_access_count {
|
if send.access_count >= max_access_count {
|
||||||
err_code!("Send does not exist or is no longer available", 404);
|
err_code!(SEND_INACCESSIBLE_MSG, 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(expiration) = send.expiration_date {
|
if let Some(expiration) = send.expiration_date {
|
||||||
if Utc::now().naive_utc() >= expiration {
|
if Utc::now().naive_utc() >= expiration {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Utc::now().naive_utc() >= send.deletion_date {
|
if Utc::now().naive_utc() >= send.deletion_date {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
|
|
||||||
if send.disabled {
|
if send.disabled {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
|
|
||||||
if send.password_hash.is_some() {
|
if send.password_hash.is_some() {
|
||||||
|
@ -279,27 +281,27 @@ fn post_access_file(
|
||||||
) -> JsonResult {
|
) -> JsonResult {
|
||||||
let mut send = match Send::find_by_uuid(&send_id, &conn) {
|
let mut send = match Send::find_by_uuid(&send_id, &conn) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => err_code!("Send does not exist or is no longer available", 404),
|
None => err_code!(SEND_INACCESSIBLE_MSG, 404),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(max_access_count) = send.max_access_count {
|
if let Some(max_access_count) = send.max_access_count {
|
||||||
if send.access_count >= max_access_count {
|
if send.access_count >= max_access_count {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(expiration) = send.expiration_date {
|
if let Some(expiration) = send.expiration_date {
|
||||||
if Utc::now().naive_utc() >= expiration {
|
if Utc::now().naive_utc() >= expiration {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if Utc::now().naive_utc() >= send.deletion_date {
|
if Utc::now().naive_utc() >= send.deletion_date {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
|
|
||||||
if send.disabled {
|
if send.disabled {
|
||||||
err_code!("Send does not exist or is no longer available", 404)
|
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||||
}
|
}
|
||||||
|
|
||||||
if send.password_hash.is_some() {
|
if send.password_hash.is_some() {
|
||||||
|
|
Laden …
In neuem Issue referenzieren