fixed a bug that stopped sessions from being deleted

This commit is contained in:
Gregory Wells
2026-03-25 10:20:20 -04:00
parent ffb4077f24
commit f491c80fa0
3 changed files with 18 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ func createUserPhoto(username string, photoData []byte) error {
}
func authenticateUser(username, password string) (UserData, error) {
logging.Event(logging.AuthenticateUser, username)
ldapServerMutex.Lock()
defer ldapServerMutex.Unlock()
if ldapServer.Connection == nil {
@@ -232,9 +233,7 @@ func logoutHandler(w http.ResponseWriter, r *http.Request) {
}
}
sessionMutex.Lock()
delete(sessions, token)
sessionMutex.Unlock()
deleteSession(token)
http.Redirect(w, r, "/login", http.StatusSeeOther)
}

View File

@@ -94,3 +94,13 @@ func validateSession(r *http.Request) (bool, *SessionData) {
logging.Infof("Validated session for %s", sessionData.data.Username)
return true, &sessionData
}
func deleteSession(session_id string) {
sessionMutex.Lock()
tokenEncoded := sha256.Sum256([]byte(session_id))
tokenEncodedString := string(tokenEncoded[:])
delete(sessions, tokenEncodedString)
sessionMutex.Unlock()
}