fix server from crashing after restart not having user data

This commit is contained in:
Gregory Wells
2026-06-08 17:56:04 -04:00
parent efdf9fdade
commit 3b31adf3e2
+9
View File
@@ -94,9 +94,18 @@ func profileHandler(w http.ResponseWriter, r *http.Request) {
return 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 { if r.Method == http.MethodGet {
tmpl := template.Must(template.ParseFiles("src/pages/profile_page.html")) tmpl := template.Must(template.ParseFiles("src/pages/profile_page.html"))
userDataMutex.RLock() userDataMutex.RLock()
tmpl.Execute(w, ProfileData{ tmpl.Execute(w, ProfileData{
Username: sessionData.UserID, Username: sessionData.UserID,
Email: userData[sessionData.UserID].Email, Email: userData[sessionData.UserID].Email,