From 3b31adf3e2462c1f54fe0db67fb2e5768b9ec649 Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Mon, 8 Jun 2026 17:56:04 -0400 Subject: [PATCH] fix server from crashing after restart not having user data --- src/main/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/main.go b/src/main/main.go index 7dda044..0b05d8a 100644 --- a/src/main/main.go +++ b/src/main/main.go @@ -94,9 +94,18 @@ func profileHandler(w http.ResponseWriter, r *http.Request) { return } + _, exists := userData[sessionData.UserID] + + if !exists { + logging.Error("Session id exists but user does not exist") + http.Redirect(w, r, "/login", http.StatusSeeOther) + return + } + if r.Method == http.MethodGet { tmpl := template.Must(template.ParseFiles("src/pages/profile_page.html")) userDataMutex.RLock() + tmpl.Execute(w, ProfileData{ Username: sessionData.UserID, Email: userData[sessionData.UserID].Email,