fix server from crashing after restart not having user data
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user