Update CORS options.

Disallow bots to be added as friends.
This commit is contained in:
Paul
2021-08-15 23:11:33 +01:00
parent f04137d50f
commit bffac8c4c0
4 changed files with 20 additions and 2 deletions

View File

@@ -1,3 +1,3 @@
#!/bin/bash
export version=0.5.2-alpha.0
export version=0.5.2-alpha.1
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs

View File

@@ -29,6 +29,7 @@ use rauth::{
auth::Auth,
options::{Template, Templates},
};
use std::str::FromStr;
use rocket_cors::AllowedOrigins;
use rocket::catchers;
use util::variables::{
@@ -69,6 +70,20 @@ async fn main() {
async fn launch_web() {
let cors = rocket_cors::CorsOptions {
allowed_origins: AllowedOrigins::All,
allowed_methods: [
"Get",
"Put",
"Post",
"Delete",
"Options",
"Head",
"Trace",
"Connect",
"Patch",
]
.iter()
.map(|s| FromStr::from_str(s).unwrap())
.collect(),
..Default::default()
}
.to_cors()

View File

@@ -36,6 +36,9 @@ pub async fn req(user: User, username: String) -> Result<Value> {
})?;
let target_user = Ref::from(target_id.to_string())?.fetch_user().await?;
if target_user.bot.is_some() {
return Err(Error::IsBot)
}
match get_relationship(&user, &target_id) {
RelationshipStatus::User => return Err(Error::NoEffect),

View File

@@ -1 +1 @@
pub const VERSION: &str = "0.5.2-alpha.0";
pub const VERSION: &str = "0.5.2-alpha.1";