From daf0e97da45b3af404fcd0ae92bcc7c87f9d93b0 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 21 May 2022 13:33:16 +0200 Subject: [PATCH] Fix comment auth --- trainav.web/Pages/Trip.cshtml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trainav.web/Pages/Trip.cshtml.cs b/trainav.web/Pages/Trip.cshtml.cs index 9a459ee..191afb4 100644 --- a/trainav.web/Pages/Trip.cshtml.cs +++ b/trainav.web/Pages/Trip.cshtml.cs @@ -54,8 +54,9 @@ public class TripModel : PageModel { if (!Request.Form.ContainsKey("comment")) return; + AuthorizedUser = db.Users.FirstOrDefault(p => p.Username == AuthUtil.GetRemoteUser(HttpContext, db)); var leg = db.Legs.First(p => p.LegId == int.Parse(Request.Form["id"])); - if (leg.UserId != AuthorizedUser.UserId) + if (leg.UserId != AuthorizedUser!.UserId) return; leg.Comment = Request.Form["comment"];