only reset ws.Authed if it's nil.

i.e. if there has been an auth and for some reason the client tried to auth again
after RequestAuth() has been called again.
This commit is contained in:
fiatjaf
2023-12-27 13:05:29 -03:00
parent 0f7d26f26e
commit b00e5b2b3f

View File

@@ -15,7 +15,9 @@ const (
func RequestAuth(ctx context.Context) { func RequestAuth(ctx context.Context) {
ws := GetConnection(ctx) ws := GetConnection(ctx)
ws.authLock.Lock() ws.authLock.Lock()
ws.Authed = make(chan struct{}) if ws.Authed == nil {
ws.Authed = make(chan struct{})
}
ws.authLock.Unlock() ws.authLock.Unlock()
ws.WriteJSON(nostr.AuthEnvelope{Challenge: &ws.Challenge}) ws.WriteJSON(nostr.AuthEnvelope{Challenge: &ws.Challenge})
} }