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,