New perm concept, reference, and adding routes.

This commit is contained in:
Paul Makles
2020-12-29 13:02:04 +00:00
parent 798047625a
commit eb382fa1ec
14 changed files with 196 additions and 46 deletions

View File

@@ -1,7 +1,22 @@
use crate::util::result::Result;
use crate::database::guards::reference::Ref;
use crate::util::result::{Error, Result};
use crate::database::entities::User;
use rocket_contrib::json::JsonValue;
#[get("/<id>")]
pub async fn req(id: String) -> Result<String> {
println!("{}", id);
Ok("LETS FUCKING GOOOO".to_string())
#[get("/<target>")]
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
let mut target = target.fetch_user().await?;
if user.id != target.id {
// Check whether we are allowed to fetch this user.
let perm = crate::database::permissions::temp_calc_perm(&user, &target).await;
if !perm.get_access() {
Err(Error::LabelMe)?
}
// Only return user relationships if the target is the caller.
target.relations = None;
}
Ok(json!(target))
}