From 2b63ec125afd58aa6d9f79d22a554f623cae7a8e Mon Sep 17 00:00:00 2001 From: BlackDex Date: Fri, 3 Nov 2023 13:04:34 +0100 Subject: [PATCH] Updated suggestions and crates - Addressed the suggestions - Updated Rocket to latest rc4 Also made the needed code changes - Updated all other crates Pinned `openssl` and `openssl-sys` --- Cargo.lock | 181 ++++++++++++++++++++++----------------- Cargo.toml | 18 ++-- src/api/admin.rs | 8 +- src/api/core/accounts.rs | 11 +-- src/db/mod.rs | 8 +- src/error.rs | 4 +- 6 files changed, 125 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f8f854c69a..719fae550c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,7 +133,7 @@ checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ "async-channel", "async-executor", - "async-io", + "async-io 1.13.0", "async-lock", "blocking", "futures-lite", @@ -153,13 +153,33 @@ dependencies = [ "futures-lite", "log", "parking", - "polling", + "polling 2.8.0", "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10da8f3146014722c89e7859e1d7bb97873125d7346d10ca642ffab794355828" +dependencies = [ + "async-lock", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling 3.3.0", + "rustix 0.38.21", + "slab", + "tracing", + "waker-fn", + "windows-sys", +] + [[package]] name = "async-lock" version = "2.8.0" @@ -175,12 +195,12 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ - "async-io", + "async-io 1.13.0", "async-lock", "async-signal", "blocking", "cfg-if", - "event-listener 3.0.0", + "event-listener 3.0.1", "futures-lite", "rustix 0.38.21", "windows-sys", @@ -188,11 +208,11 @@ dependencies = [ [[package]] name = "async-signal" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a5415b7abcdc9cd7d63d6badba5288b2ca017e3fbd4173b8f405449f1a2399" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io", + "async-io 2.1.0", "async-lock", "atomic-waker", "cfg-if", @@ -212,7 +232,7 @@ checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-channel", "async-global-executor", - "async-io", + "async-io 1.13.0", "async-lock", "async-process", "crossbeam-utils", @@ -395,9 +415,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -493,9 +513,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7" +checksum = "e23185c0e21df6ed832a12e2bda87c7d1def6842881fb634a8511ced741b0d76" dependencies = [ "chrono", "chrono-tz-build", @@ -504,9 +524,9 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f5ebdc942f57ed96d560a6d1a459bae5851102a25d5bf89dc04ae453e31ecf" +checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" dependencies = [ "parse-zoneinfo", "phf", @@ -912,9 +932,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" +checksum = "01cec0252c2afff729ee6f00e903d479fba81784c8e2bd77447673471fdfaea1" dependencies = [ "concurrent-queue", "parking", @@ -950,14 +970,14 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.11" +version = "0.10.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a014ac935975a70ad13a3bff2463b1c1b083b35ae4cb6309cfc59476aa7a181f" +checksum = "649f3e5d826594057e9a519626304d8da859ea8a0b18ce99500c586b8d45faee" dependencies = [ "atomic 0.6.0", "pear", "serde", - "toml 0.8.5", + "toml 0.8.6", "uncased", "version_check", ] @@ -1437,9 +1457,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -1526,9 +1546,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -2222,6 +2242,20 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "polling" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.21", + "tracing", + "windows-sys", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -2553,8 +2587,9 @@ dependencies = [ [[package]] name = "rocket" -version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" +version = "0.5.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ae34c956708013335f62150ff64e133be7f9e8ca60203852bc7b13d6044d01" dependencies = [ "async-stream", "async-trait", @@ -2564,7 +2599,7 @@ dependencies = [ "either", "figment", "futures", - "indexmap 2.0.2", + "indexmap 2.1.0", "log", "memchr", "multer", @@ -2590,12 +2625,13 @@ dependencies = [ [[package]] name = "rocket_codegen" -version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" +version = "0.5.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "896efc56a554a4e1fd03df1d8186c955b803aa652bbe8725a731f64e20f9cee8" dependencies = [ "devise", "glob", - "indexmap 2.0.2", + "indexmap 2.1.0", "proc-macro2", "quote", "rocket_http", @@ -2606,15 +2642,16 @@ dependencies = [ [[package]] name = "rocket_http" -version = "0.5.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" +version = "0.5.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b9b7377bab513717a00ca4f91fe1378328b078e7705bfe5f6b69635e9f1719" dependencies = [ "cookie 0.18.0", "either", "futures", "http", "hyper", - "indexmap 2.0.2", + "indexmap 2.1.0", "log", "memchr", "pear", @@ -2635,8 +2672,9 @@ dependencies = [ [[package]] name = "rocket_ws" -version = "0.1.0-rc.3" -source = "git+https://github.com/SergioBenitez/Rocket?rev=923b61edf37424692a32727513b0062283ead741#923b61edf37424692a32727513b0062283ead741" +version = "0.1.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8973e9ccbe590e2eff2a1d455b9372b4a12e32eaebdf2cf51c61db272f9a99d" dependencies = [ "rocket", "tokio-tungstenite", @@ -2849,9 +2887,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2879,17 +2917,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha1" version = "0.10.6" @@ -3309,14 +3336,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efaf127c78d5339cc547cce4e4d973bd5e4f56e949a06d091c082ebeef2f800" +checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.5", + "toml_edit 0.20.7", ] [[package]] @@ -3334,7 +3361,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -3343,11 +3370,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.5" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782bf6c2ddf761c1e7855405e8975472acf76f7f36d0d4328bd3b7a2fae12a85" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -3356,13 +3383,13 @@ dependencies = [ [[package]] name = "totp-lite" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc496875d9c8fe9a0ce19e3ee8e8808c60376831a439543f0aac71c9dd129fa" +checksum = "f8e43134db17199f7f721803383ac5854edd0d3d523cc34dba321d6acfbe76c3" dependencies = [ "digest", "hmac", - "sha-1", + "sha1", "sha2", ] @@ -3714,9 +3741,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3724,9 +3751,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -3739,9 +3766,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -3751,9 +3778,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3761,9 +3788,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -3774,9 +3801,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wasm-streams" @@ -3793,9 +3820,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -3956,9 +3983,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32" dependencies = [ "memchr", ] @@ -4000,18 +4027,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.15" +version = "0.7.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" +checksum = "e50cbb27c30666a6108abd6bc7577556265b44f243e2be89a8bc4e07a528c107" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.15" +version = "0.7.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" +checksum = "a25f293fe55f0a48e7010d65552bb63704f6ceb55a1a385da10d41d8f78e4a3d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 3c212600239..4a2ac9afd25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,9 +55,8 @@ num-traits = "0.2.17" num-derive = "0.4.1" # Web framework -rocket = { version = "0.5.0-rc.3", features = ["tls", "json"], default-features = false } -# rocket_ws = { version ="0.1.0-rc.3" } -rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = "923b61edf37424692a32727513b0062283ead741" } # v0.5rc branch +rocket = { version = "0.5.0-rc.4", features = ["tls", "json"], default-features = false } +rocket_ws = { version ="0.1.0-rc.4" } # WebSockets libraries rmpv = "1.0.1" # MessagePack library @@ -71,7 +70,7 @@ tokio = { version = "1.33.0", features = ["rt-multi-thread", "fs", "io-util", "p # A generic serialization/deserialization framework serde = { version = "1.0.190", features = ["derive"] } -serde_json = "1.0.107" +serde_json = "1.0.108" # A safe, extensible ORM and Query builder diesel = { version = "2.1.3", features = ["chrono", "r2d2"] } @@ -90,7 +89,7 @@ uuid = { version = "1.5.0", features = ["v4"] } # Date and time libraries chrono = { version = "0.4.31", features = ["clock", "serde"], default-features = false } -chrono-tz = "0.8.3" +chrono-tz = "0.8.4" time = "0.3.30" # Job scheduler @@ -103,7 +102,7 @@ data-encoding = "2.4.0" jsonwebtoken = "9.1.0" # TOTP library -totp-lite = "2.0.0" +totp-lite = "2.0.1" # Yubico Library yubico = { version = "0.11.0", features = ["online-tokio"], default-features = false } @@ -139,7 +138,7 @@ cookie = "0.16.2" cookie_store = "0.19.1" # Used by U2F, JWT and PostgreSQL -openssl = "0.10.57" +openssl = "=0.10.57" # Set openssl-sys fixed to v0.9.92 to prevent building issues with musl, arm and 32bit pointer width # It will force add a dynamically linked library which prevents the build from being static openssl-sys = "=0.9.92" @@ -166,11 +165,6 @@ argon2 = "0.5.2" rpassword = "7.2.0" -[patch.crates-io] -rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = '923b61edf37424692a32727513b0062283ead741' } # v0.5rc branch -# rocket_ws = { git = 'https://github.com/SergioBenitez/Rocket', rev = '923b61edf37424692a32727513b0062283ead741' } # v0.5rc branch - - # Strip debuginfo from the release builds # Also enable thin LTO for some optimizations [profile.release] diff --git a/src/api/admin.rs b/src/api/admin.rs index 96f893dbdff..ae304253882 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -312,7 +312,7 @@ async fn test_smtp(data: Json, _token: AdminToken) -> EmptyResult { #[get("/logout")] fn logout(cookies: &CookieJar<'_>) -> Redirect { - cookies.remove(Cookie::build((COOKIE_NAME, "")).path(admin_path())); + cookies.remove(Cookie::build(COOKIE_NAME).path(admin_path())); Redirect::to(admin_path()) } @@ -785,16 +785,16 @@ impl<'r> FromRequest<'r> for AdminToken { if requested_page.is_empty() { return Outcome::Forward(Status::Unauthorized); } else { - return Outcome::Failure((Status::Unauthorized, "Unauthorized")); + return Outcome::Error((Status::Unauthorized, "Unauthorized")); } } }; if decode_admin(access_token).is_err() { // Remove admin cookie - cookies.remove(Cookie::build((COOKIE_NAME, "")).path(admin_path())); + cookies.remove(Cookie::build(COOKIE_NAME).path(admin_path())); error!("Invalid or expired admin JWT. IP: {}.", &ip.ip); - return Outcome::Failure((Status::Unauthorized, "Session expired")); + return Outcome::Error((Status::Unauthorized, "Session expired")); } Outcome::Success(Self { diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 6f6e2f3d4e1..c3ad9e7f1a7 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -921,26 +921,23 @@ impl<'r> FromRequest<'r> for KnownDevice { let email_bytes = match data_encoding::BASE64URL_NOPAD.decode(email_b64.as_bytes()) { Ok(bytes) => bytes, Err(_) => { - return Outcome::Failure(( - Status::BadRequest, - "X-Request-Email value failed to decode as base64url", - )); + return Outcome::Error((Status::BadRequest, "X-Request-Email value failed to decode as base64url")); } }; match String::from_utf8(email_bytes) { Ok(email) => email, Err(_) => { - return Outcome::Failure((Status::BadRequest, "X-Request-Email value failed to decode as UTF-8")); + return Outcome::Error((Status::BadRequest, "X-Request-Email value failed to decode as UTF-8")); } } } else { - return Outcome::Failure((Status::BadRequest, "X-Request-Email value is required")); + return Outcome::Error((Status::BadRequest, "X-Request-Email value is required")); }; let uuid = if let Some(uuid) = req.headers().get_one("X-Device-Identifier") { uuid.to_string() } else { - return Outcome::Failure((Status::BadRequest, "X-Device-Identifier value is required")); + return Outcome::Error((Status::BadRequest, "X-Device-Identifier value is required")); }; Outcome::Success(KnownDevice { diff --git a/src/db/mod.rs b/src/db/mod.rs index 9f3582d7d66..f59ac98de1e 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -7,7 +7,6 @@ use diesel::{ use rocket::{ http::Status, - outcome::IntoOutcome, request::{FromRequest, Outcome}, Request, }; @@ -413,8 +412,11 @@ impl<'r> FromRequest<'r> for DbConn { async fn from_request(request: &'r Request<'_>) -> Outcome { match request.rocket().state::() { - Some(p) => p.get().await.map_err(|_| ()).into_outcome(Status::ServiceUnavailable), - None => Outcome::Failure((Status::InternalServerError, ())), + Some(p) => match p.get().await { + Ok(dbconn) => Outcome::Success(dbconn), + _ => Outcome::Error((Status::ServiceUnavailable, ())), + }, + None => Outcome::Error((Status::InternalServerError, ())), } } } diff --git a/src/error.rs b/src/error.rs index f63bc9da1c4..784aad6aded 100644 --- a/src/error.rs +++ b/src/error.rs @@ -289,10 +289,10 @@ macro_rules! err_json { macro_rules! err_handler { ($expr:expr) => {{ error!(target: "auth", "Unauthorized Error: {}", $expr); - return ::rocket::request::Outcome::Failure((rocket::http::Status::Unauthorized, $expr)); + return ::rocket::request::Outcome::Error((rocket::http::Status::Unauthorized, $expr)); }}; ($usr_msg:expr, $log_value:expr) => {{ error!(target: "auth", "Unauthorized Error: {}. {}", $usr_msg, $log_value); - return ::rocket::request::Outcome::Failure((rocket::http::Status::Unauthorized, $usr_msg)); + return ::rocket::request::Outcome::Error((rocket::http::Status::Unauthorized, $usr_msg)); }}; }