Add an admin flag to user

This commit is contained in:
Greg Burri 2025-01-20 01:25:19 +01:00
parent f1ea7841a2
commit 4c9742af65
5 changed files with 32 additions and 14 deletions

View file

@ -8,6 +8,7 @@ pub struct User {
pub name: String,
pub email: String,
pub lang: String,
pub is_admin: bool,
}
#[derive(Debug, FromRow)]
@ -39,6 +40,10 @@ pub struct Recipe {
pub groups: Vec<Group>,
}
pub fn can_user_edit_recipe(user: &User, recipe: &Recipe) -> bool {
user.is_admin || recipe.user_id == user.id
}
#[derive(Debug, FromRow)]
pub struct Group {
pub id: i64,