fix: short-circuit fetch user route if self

This commit is contained in:
Paul Makles
2022-04-29 13:10:52 +01:00
parent 278d795d50
commit 0651a501f6
2 changed files with 6 additions and 2 deletions

View File

@@ -8,6 +8,10 @@ use rocket::{serde::json::Json, State};
#[openapi(tag = "User Information")]
#[get("/<target>")]
pub async fn req(db: &State<Database>, user: User, target: Ref) -> Result<Json<User>> {
if target.id == user.id {
return Ok(Json(user));
}
let target = target.as_user(db).await?;
let permissions = perms(&user).user(&target).calc_user(db).await;