diff --git a/crates/core/database/src/util/oauth2.rs b/crates/core/database/src/util/oauth2.rs index 9fe5a83c..6cc136e0 100644 --- a/crates/core/database/src/util/oauth2.rs +++ b/crates/core/database/src/util/oauth2.rs @@ -125,10 +125,6 @@ pub fn scope_can_access_route(scope: &str, request: &Request<'_>) -> bool { match scope { "identify" => { - println!("{:?}", request.method() == Method::Get); - println!("{:?}", segments.get(0)); - println!("{:?}", segments.get(1)); - request.method() == Method::Get && segments.get(0) == Some("users") && segments.get(1) == Some("@me") diff --git a/crates/core/models/src/v0/oauth2.rs b/crates/core/models/src/v0/oauth2.rs index 73525439..91df6554 100644 --- a/crates/core/models/src/v0/oauth2.rs +++ b/crates/core/models/src/v0/oauth2.rs @@ -1,4 +1,4 @@ -use crate::v0::{Bot, User}; +use crate::v0::{PublicBot, User}; auto_derived!( pub struct OAuth2AuthorizeAuthResponse { @@ -7,7 +7,7 @@ auto_derived!( } pub struct OAuth2AuthorizeInfoResponse { - pub bot: Bot, + pub bot: PublicBot, pub user: User, } diff --git a/crates/delta/src/routes/oauth2/authorize_info.rs b/crates/delta/src/routes/oauth2/authorize_info.rs index a6631cfe..2c4a9459 100644 --- a/crates/delta/src/routes/oauth2/authorize_info.rs +++ b/crates/delta/src/routes/oauth2/authorize_info.rs @@ -7,13 +7,15 @@ use rocket::{form::Form, serde::json::Json, State}; /// /// Fetches the information needed for displaying on the OAuth grant page #[openapi(tag = "OAuth2")] -#[get("/authorize", data="")] +#[get("/authorize?")] pub async fn info( db: &State, user: User, - info: Form, + info: v0::OAuth2AuthorizationForm, ) -> Result> { let bot = Reference::from_unchecked(info.client_id.to_string()).as_bot(db).await?; + let bot_user = Reference::from_unchecked(bot.id.clone()).as_user(db).await?; + let public_bot = bot.clone().into_public_bot(bot_user); let Some(oauth2) = &bot.oauth2 else { return Err(create_error!(InvalidOperation)); @@ -24,7 +26,7 @@ pub async fn info( }; Ok(Json(v0::OAuth2AuthorizeInfoResponse { - bot: bot.into(), + bot: public_bot, user: user.into(db, None).await })) } \ No newline at end of file