Compare commits

..

No commits in common. "2bc426be52e25b0669a85b2d23042c0f253ddc3d" and "6e72e2a753d5aa22f4d3ee062c85cb66459afed3" have entirely different histories.

2 changed files with 9 additions and 10 deletions

View File

@ -1001,7 +1001,6 @@ special_user!(SchnupperBetreuerUser, +"schnupper-betreuer");
special_user!(VorstandUser, +"Vorstand");
special_user!(EventUser, +"manage_events");
special_user!(AllowedToEditPaymentStatusUser, +"kassier", +"admin");
special_user!(ManageUserUser, +"admin", +"schriftfuehrer");
#[derive(FromRow, Serialize, Deserialize, Clone, Debug)]
pub struct UserWithRolesAndMembershipPdf {

View File

@ -7,7 +7,7 @@ use crate::{
logbook::Logbook,
role::Role,
user::{
AdminUser, AllowedToEditPaymentStatusUser, ManageUserUser, SchnupperBetreuerUser, User,
AdminUser, AllowedToEditPaymentStatusUser, SchnupperBetreuerUser, User,
UserWithDetails, UserWithMembershipPdf, UserWithRolesAndMembershipPdf, VorstandUser,
},
},
@ -56,7 +56,7 @@ async fn index(
.collect();
let user: User = user.into_inner();
let allowed_to_edit = ManageUserUser::new(db, user.clone()).await.is_some();
let allowed_to_edit = user.has_role(db, "admin").await;
let users: Vec<UserWithRolesAndMembershipPdf> = join_all(user_futures).await;
@ -90,7 +90,7 @@ async fn index_admin(
let users: Vec<UserWithRolesAndMembershipPdf> = join_all(user_futures).await;
let user: User = user.user;
let allowed_to_edit = ManageUserUser::new(db, user.clone()).await.is_some();
let allowed_to_edit = user.has_role(db, "admin").await;
let roles = Role::all(db).await;
let families = Family::all_with_members(db).await;
@ -215,7 +215,7 @@ async fn fees_paid(
#[get("/user/<user>/send-welcome-mail")]
async fn send_welcome_mail(
db: &State<SqlitePool>,
_admin: ManageUserUser,
_admin: AdminUser,
config: &State<Config>,
user: i32,
) -> Flash<Redirect> {
@ -233,7 +233,7 @@ async fn send_welcome_mail(
}
#[get("/user/<user>/reset-pw")]
async fn resetpw(db: &State<SqlitePool>, admin: ManageUserUser, user: i32) -> Flash<Redirect> {
async fn resetpw(db: &State<SqlitePool>, admin: AdminUser, user: i32) -> Flash<Redirect> {
let user = User::find_by_id(db, user).await;
match user {
Some(user) => {
@ -253,7 +253,7 @@ async fn resetpw(db: &State<SqlitePool>, admin: ManageUserUser, user: i32) -> Fl
}
#[get("/user/<user>/delete")]
async fn delete(db: &State<SqlitePool>, admin: ManageUserUser, user: i32) -> Flash<Redirect> {
async fn delete(db: &State<SqlitePool>, admin: AdminUser, user: i32) -> Flash<Redirect> {
let user = User::find_by_id(db, user).await;
Log::create(db, format!("{} deleted user: {user:?}", admin.user.name)).await;
match user {
@ -290,7 +290,7 @@ pub struct UserEditForm<'a> {
async fn update(
db: &State<SqlitePool>,
data: Form<UserEditForm<'_>>,
admin: ManageUserUser,
admin: AdminUser,
) -> Flash<Redirect> {
let user = User::find_by_id(db, data.id).await;
Log::create(
@ -313,7 +313,7 @@ async fn update(
#[get("/user/<user>/membership")]
async fn download_membership_pdf(
db: &State<SqlitePool>,
admin: ManageUserUser,
admin: AdminUser,
user: i32,
) -> (ContentType, Vec<u8>) {
let user = User::find_by_id(db, user).await.unwrap();
@ -339,7 +339,7 @@ struct UserAddForm<'r> {
async fn create(
db: &State<SqlitePool>,
data: Form<UserAddForm<'_>>,
admin: ManageUserUser,
admin: AdminUser,
) -> Flash<Redirect> {
if User::create(db, data.name).await {
Log::create(