extract_uid for more legibility when we need to pull 'id' from user parameters

This commit is contained in:
shockrah 2021-01-23 17:10:43 -08:00
parent 085bad75fd
commit 9e505bd2bb

View File

@ -27,4 +27,11 @@ pub async fn parse_json_params(body_raw: &mut Body) -> Result<Value, serde_json:
values = serde_json::from_slice(bytes)?;
}
Ok(values)
}
#[inline]
pub fn extract_uid(values: &Value) -> u64 {
// pulling 'id' from user params is safe because the
// auth modules guarantees this to be there already
values.get("id").unwrap().as_u64().unwrap()
}