From c27a2ad15e66ba73d2490a4c716af2597e5f542f Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 28 Apr 2024 19:16:38 +0200 Subject: [PATCH] don't respond with 500 if no rower is selected --- src/tera/log.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index 2c618b0..0cdca4a 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -250,7 +250,13 @@ async fn create_kiosk( } else if let Some(shipmaster) = data.shipmaster { User::find_by_id(db, shipmaster as i32).await.unwrap() } else { - User::find_by_id(db, data.rowers[0] as i32).await.unwrap() + let Some(rower) = data.rowers.get(0) else { + return Flash::error( + Redirect::to("/log"), + "Ausfahrt ohne Benutzer kann nicht angelegt werden.", + ); + }; + User::find_by_id(db, *rower as i32).await.unwrap() }; Log::create( db,