[fix] link create_board_post to ManageBoards permission

This commit is contained in:
hkau 2024-03-31 12:15:44 -04:00
parent 4fabded7f8
commit e364a7f0a3
2 changed files with 8 additions and 4 deletions

View File

@ -317,7 +317,7 @@ pub async fn create_post_request(
Option::None
},
if token_user.is_some() {
Option::Some(token_user.clone().unwrap().user.role)
Option::Some(token_user.clone().unwrap().level)
} else {
Option::None
},

View File

@ -2001,8 +2001,8 @@ impl PufferDB {
pub async fn create_board_post(
&self,
props: &mut BoardPostLog,
as_user: Option<String>, // username of user posting
as_role: Option<String>, // role of user posting
as_user: Option<String>, // username of user posting
as_role: Option<RoleLevel>, // role of user posting
) -> DefaultReturn<Option<String>> {
let p: &mut BoardPostLog = props; // borrowed props
@ -2064,7 +2064,11 @@ impl PufferDB {
&& board.allow_open_posting.unwrap() == String::from("no")
{
let can_post = as_user.is_some()
&& ((as_user.as_ref().unwrap() == &board.owner) | (as_role.unwrap() == "staff"));
&& ((as_user.as_ref().unwrap() == &board.owner)
| (as_role
.unwrap()
.permissions
.contains(&String::from("ManageBoards"))));
if can_post == false {
return DefaultReturn {