diff --git a/Cargo.lock b/Cargo.lock index 8e1aab1..6905e1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -803,9 +803,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -1362,9 +1362,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -1526,8 +1526,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -2635,9 +2637,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" dependencies = [ "cc", ] @@ -2669,9 +2671,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", @@ -2680,26 +2682,29 @@ dependencies = [ "rustc-hash", "rustls", "socket2", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring", "rustc-hash", "rustls", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] @@ -2791,7 +2796,7 @@ dependencies = [ "rand_chacha", "simd_helpers", "system-deps", - "thiserror", + "thiserror 1.0.69", "v_frame", "wasm-bindgen", ] @@ -3067,6 +3072,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -3350,7 +3358,7 @@ dependencies = [ "sha2", "smallvec", "sqlformat", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", @@ -3436,7 +3444,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 1.0.69", "tracing", "uuid", "whoami", @@ -3476,7 +3484,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 1.0.69", "tracing", "uuid", "whoami", @@ -3682,7 +3690,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -3696,6 +3713,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -4220,6 +4248,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webp" version = "0.3.0" @@ -4601,7 +4639,7 @@ dependencies = [ "flate2", "indexmap", "memchr", - "thiserror", + "thiserror 1.0.69", "zopfli", ] diff --git a/src/api/users/me/mod.rs b/src/api/users/me/mod.rs index 7489b2e..2ab55d5 100644 --- a/src/api/users/me/mod.rs +++ b/src/api/users/me/mod.rs @@ -4,6 +4,7 @@ mod export; mod gi; mod import; mod password; +mod renew; mod uids; mod username; mod zzz; @@ -35,6 +36,7 @@ pub fn openapi() -> utoipa::openapi::OpenApi { openapi.merge(gi::openapi()); openapi.merge(import::openapi()); openapi.merge(password::openapi()); + openapi.merge(renew::openapi()); openapi.merge(uids::openapi()); openapi.merge(username::openapi()); openapi.merge(zzz::openapi()); @@ -49,6 +51,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .configure(gi::configure) .configure(import::configure) .configure(password::configure) + .configure(renew::configure) .configure(uids::configure) .configure(username::configure) .configure(zzz::configure); diff --git a/src/api/users/me/renew/mod.rs b/src/api/users/me/renew/mod.rs new file mode 100644 index 0000000..6442f11 --- /dev/null +++ b/src/api/users/me/renew/mod.rs @@ -0,0 +1,40 @@ +use actix_session::Session; +use actix_web::{post, web, HttpResponse, Responder}; +use utoipa::OpenApi; + +use crate::api::ApiResult; + +#[derive(OpenApi)] +#[openapi( + tags((name = "users/me/renew")), + paths(post_renew) +)] +struct ApiDoc; + +pub fn openapi() -> utoipa::openapi::OpenApi { + ApiDoc::openapi() +} + +pub fn configure(cfg: &mut web::ServiceConfig) { + cfg.service(post_renew); +} + +#[utoipa::path( + tag = "users/me/renew", + get, + path = "/api/users/me/renew", + responses( + (status = 200, description = "Successfully renewed", body = String), + (status = 400, description = "Not logged in"), + ) +)] +#[post("/api/users/me/renew")] +async fn post_renew(session: Session) -> ApiResult { + let Ok(Some(username)) = session.get::("username") else { + return Ok(HttpResponse::BadRequest().finish()); + }; + + session.renew(); + + Ok(HttpResponse::Ok().json(username)) +}