diff --git a/src/main.rs b/src/main.rs index 2a4bc08..b944251 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,28 +78,35 @@ fn login() -> Redirect { #[derive(FromForm)] struct Login<'r> { + token_type: &'r str, access_token: &'r str, expires_in: u64, + scope: &'r str, } #[post("/login", data = "")] fn post_login(login: Form>, cookies: &CookieJar<'_>) -> Redirect { - cookies.add_private(Cookie::new(TOKEN_COOKIE, login.access_token.to_owned())); - cookies.add(Cookie::new(TOKEN_EXPIRE_COOKIE, (Utc::now() + Duration::seconds(login.expires_in as i64)).timestamp().to_string())); + if login.token_type != "Bearer" || login.scope != "guilds.join+identify+guilds" { + cookies.add_private(Cookie::new(TOKEN_COOKIE, login.access_token.to_owned())); + cookies.add(Cookie::new(TOKEN_EXPIRE_COOKIE, (Utc::now() + Duration::seconds(login.expires_in as i64)).timestamp().to_string())); + } Redirect::to("/") } #[get("/success")] fn success() -> RawHtml<&'static str> { - RawHtml("
- - -
+ RawHtml("
") }