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
|
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user