Add an admin flag to user
This commit is contained in:
parent
f1ea7841a2
commit
4c9742af65
5 changed files with 32 additions and 14 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue