khatru: fix multi-user auth stupid bug.

This commit is contained in:
fiatjaf
2025-09-06 22:29:35 -03:00
parent 4754518278
commit 9933bb7865

View File

@@ -320,7 +320,7 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
wsBaseUrl := strings.Replace(rl.getBaseURL(r), "http", "ws", 1) wsBaseUrl := strings.Replace(rl.getBaseURL(r), "http", "ws", 1)
if pubkey, ok := nip42.ValidateAuthEvent(env.Event, ws.Challenge, wsBaseUrl); ok { if pubkey, ok := nip42.ValidateAuthEvent(env.Event, ws.Challenge, wsBaseUrl); ok {
total := len(ws.AuthedPublicKeys) - 1 total := len(ws.AuthedPublicKeys)
ws.authLock.Lock() ws.authLock.Lock()
if idx := slices.Index(ws.AuthedPublicKeys, pubkey); idx == -1 { if idx := slices.Index(ws.AuthedPublicKeys, pubkey); idx == -1 {
// this public key is not authenticated // this public key is not authenticated