don't allow registration for own events

This commit is contained in:
philipp 2023-03-14 17:05:20 +01:00
parent 48c9a481cc
commit 38d8197a48

View File

@ -38,6 +38,25 @@ async fn register(
); );
} }
if let Some(cox_id) = register.cox_id {
let trip = trip::Entity::find_by_id(cox_id)
.one(db.inner())
.await
.unwrap()
.unwrap();
if trip.user_id == user.id {
log::warn!(
"{} tried to register for his own trip ({})",
user.name,
trip.id
);
return Flash::error(
Redirect::to("/"),
"Du kannst an deinen eigenen Ausfahrten nicht teilnehmen...",
);
}
}
let user = user::Model::find_or_create_user(&register.name, db.inner()).await; let user = user::Model::find_or_create_user(&register.name, db.inner()).await;
let day = format!("{}", day.day.format("%Y-%m-%d")); let day = format!("{}", day.day.format("%Y-%m-%d"));