diff --git a/Cargo.lock b/Cargo.lock index 85243f11..54a0f2a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2528,7 +2528,7 @@ dependencies = [ [[package]] name = "rauth" version = "0.3.0" -source = "git+https://gitlab.insrt.uk/insert/rauth?rev=19bef300ecc269c028e3d746f0a2f09842d3b37b#19bef300ecc269c028e3d746f0a2f09842d3b37b" +source = "git+https://github.com/insertish/rauth?rev=19bef300ecc269c028e3d746f0a2f09842d3b37b#19bef300ecc269c028e3d746f0a2f09842d3b37b" dependencies = [ "chrono", "handlebars", diff --git a/Cargo.toml b/Cargo.toml index c9be9731..e1e6c522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ async-std = { version = "1.8.0", features = ["tokio1", "tokio02", "attributes"] web-push = "0.7.2" many-to-many = "0.1.2" lettre = "0.10.0-alpha.4" -rauth = { git = "https://gitlab.insrt.uk/insert/rauth", rev = "19bef300ecc269c028e3d746f0a2f09842d3b37b" } +rauth = { git = "https://github.com/insertish/rauth", rev = "19bef300ecc269c028e3d746f0a2f09842d3b37b" } hive_pubsub = { git = "https://gitlab.insrt.uk/insert/hive", rev = "a89826df2b30166220e68a6ed01a58b751456604", features = ["mongo"] } # web diff --git a/src/routes/bots/create.rs b/src/routes/bots/create.rs index fab17ac7..e8231b7f 100644 --- a/src/routes/bots/create.rs +++ b/src/routes/bots/create.rs @@ -24,6 +24,10 @@ pub struct Data { #[post("/create", data = "")] pub async fn create_bot(user: User, info: Json) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let info = info.into_inner(); info.validate() .map_err(|error| Error::FailedValidation { error })?; diff --git a/src/routes/bots/delete.rs b/src/routes/bots/delete.rs index 45efe287..c374fe4d 100644 --- a/src/routes/bots/delete.rs +++ b/src/routes/bots/delete.rs @@ -6,6 +6,10 @@ use mongodb::bson::doc; #[delete("/")] pub async fn delete_bot(user: User, target: Ref) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let bot = target.fetch_bot().await?; if bot.owner != user.id { return Err(Error::MissingPermission); diff --git a/src/routes/bots/edit.rs b/src/routes/bots/edit.rs index b0717066..546bd4d2 100644 --- a/src/routes/bots/edit.rs +++ b/src/routes/bots/edit.rs @@ -26,6 +26,10 @@ pub struct Data { #[patch("/", data = "")] pub async fn edit_bot(user: User, target: Ref, data: Json) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let data = data.into_inner(); data.validate() .map_err(|error| Error::FailedValidation { error })?; diff --git a/src/routes/bots/fetch.rs b/src/routes/bots/fetch.rs index 2820bef5..b3b20491 100644 --- a/src/routes/bots/fetch.rs +++ b/src/routes/bots/fetch.rs @@ -5,6 +5,10 @@ use serde_json::Value; #[get("/")] pub async fn fetch_bot(user: User, target: Ref) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let bot = target.fetch_bot().await?; if !bot.public { diff --git a/src/routes/bots/fetch_owned.rs b/src/routes/bots/fetch_owned.rs index 42f08b15..d9deb731 100644 --- a/src/routes/bots/fetch_owned.rs +++ b/src/routes/bots/fetch_owned.rs @@ -7,6 +7,10 @@ use serde_json::Value; #[get("/@me")] pub async fn fetch_owned_bots(user: User) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let bots = get_collection("bots") .find( doc! { diff --git a/src/routes/bots/fetch_public.rs b/src/routes/bots/fetch_public.rs index 33bf82f2..181bb391 100644 --- a/src/routes/bots/fetch_public.rs +++ b/src/routes/bots/fetch_public.rs @@ -5,6 +5,10 @@ use serde_json::Value; #[get("//invite")] pub async fn fetch_public_bot(user: User, target: Ref) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let bot = target.fetch_bot().await?; if !bot.public { diff --git a/src/routes/bots/invite.rs b/src/routes/bots/invite.rs index b12b3ede..eb24b5f7 100644 --- a/src/routes/bots/invite.rs +++ b/src/routes/bots/invite.rs @@ -23,6 +23,10 @@ pub enum Destination { #[post("//invite", data = "")] pub async fn invite_bot(user: User, target: Ref, dest: Json) -> Result { + if user.bot.is_some() { + return Err(Error::IsBot) + } + let bot = target.fetch_bot().await?; if !bot.public {