Skip to content
Snippets Groups Projects
Commit 00d56d72 authored by Jeremy Lin's avatar Jeremy Lin
Browse files

Send access check fixes

Adjust checks for max access count, expiration date, and deletion date.
The date checks aren't that important, but the access count check
currently allows one more access than it should.
parent 7436b454
No related branches found
No related tags found
No related merge requests found
......@@ -197,18 +197,18 @@ fn post_access(access_id: String, data: JsonUpcase<SendAccessData>, conn: DbConn
};
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!("Max access count reached", 404);
}
}
if let Some(expiration) = send.expiration_date {
if Utc::now().naive_utc() > expiration {
if Utc::now().naive_utc() >= expiration {
err_code!("Send has expired", 404)
}
}
if Utc::now().naive_utc() > send.deletion_date {
if Utc::now().naive_utc() >= send.deletion_date {
err_code!("Send has been deleted", 404)
}
......@@ -248,18 +248,18 @@ fn post_access_file(
};
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!("Max access count reached", 404);
}
}
if let Some(expiration) = send.expiration_date {
if Utc::now().naive_utc() > expiration {
if Utc::now().naive_utc() >= expiration {
err_code!("Send has expired", 404)
}
}
if Utc::now().naive_utc() > send.deletion_date {
if Utc::now().naive_utc() >= send.deletion_date {
err_code!("Send has been deleted", 404)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment