diff --git a/Cargo.lock b/Cargo.lock index d927548..cd8dce3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,6 +161,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + [[package]] name = "base64ct" version = "1.5.3" @@ -346,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "344adc371239ef32293cb1c4fe519592fcf21206c79c02854320afcdf3ab4917" dependencies = [ "aes-gcm", - "base64", + "base64 0.13.1", "hkdf", "percent-encoding", "rand 0.8.5", @@ -1655,7 +1661,7 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eeaf26a72311c087f8c5ba617c96fac67a5c04f430e716ac8d8ab2de62e23368" dependencies = [ - "base64", + "base64 0.13.1", "chrono", "getrandom 0.2.8", "http", @@ -2189,9 +2195,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "reminder-rs" -version = "1.6.13" +version = "1.6.14" dependencies = [ - "base64", + "base64 0.21.2", "chrono", "chrono-tz 0.8.1", "dotenv", @@ -2219,7 +2225,7 @@ dependencies = [ name = "reminder_web" version = "0.1.0" dependencies = [ - "base64", + "base64 0.13.1", "chrono", "chrono-tz 0.5.3", "csv", @@ -2250,7 +2256,7 @@ version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "encoding_rs", "futures-core", @@ -2471,7 +2477,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" dependencies = [ - "base64", + "base64 0.13.1", ] [[package]] @@ -2637,7 +2643,7 @@ checksum = "82fd5e7b5858ad96e99d440138f34f5b98e1b959ebcd3a1036203b30e78eb788" dependencies = [ "async-trait", "async-tungstenite", - "base64", + "base64 0.13.1", "bitflags", "bytes", "cfg-if", @@ -3224,7 +3230,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" dependencies = [ - "base64", + "base64 0.13.1", "byteorder", "bytes", "http", diff --git a/Cargo.toml b/Cargo.toml index e691030..cfbe06f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ rmp-serde = "1.1" rand = "0.8" levenshtein = "1.0" sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono", "migrate"]} -base64 = "0.13" +base64 = "0.21.0" [dependencies.postman] path = "postman" diff --git a/web/src/lib.rs b/web/src/lib.rs index 0e5240d..f0f7904 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -134,7 +134,14 @@ pub async fn initialize( routes::help_iemanager, ], ) - .mount("/login", routes![routes::login::discord_login, routes::login::discord_callback]) + .mount( + "/login", + routes![ + routes::login::discord_login, + routes::login::discord_logout, + routes::login::discord_callback + ], + ) .mount( "/dashboard", routes![ diff --git a/web/src/routes/login.rs b/web/src/routes/login.rs index 1fd4196..fc22e44 100644 --- a/web/src/routes/login.rs +++ b/web/src/routes/login.rs @@ -11,7 +11,7 @@ use rocket::{ }; use serenity::model::user::User; -use crate::consts::DISCORD_API; +use crate::{consts::DISCORD_API, routes}; #[get("/discord")] pub async fn discord_login( @@ -52,6 +52,15 @@ pub async fn discord_login( Redirect::to(auth_url.to_string()) } +#[get("/discord/logout")] +pub async fn discord_logout(cookies: &CookieJar<'_>) -> Redirect { + cookies.remove_private(Cookie::named("username")); + cookies.remove_private(Cookie::named("userid")); + cookies.remove_private(Cookie::named("access_token")); + + Redirect::to(uri!(routes::index)) +} + #[get("/discord/authorized?&")] pub async fn discord_callback( code: &str, diff --git a/web/templates/dashboard.html.tera b/web/templates/dashboard.html.tera index ba5c42c..b137b5f 100644 --- a/web/templates/dashboard.html.tera +++ b/web/templates/dashboard.html.tera @@ -250,7 +250,7 @@