mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Simple refactoring to avoid empty challenges.
This commit is contained in:
parent
86a9fb2af5
commit
4f774ae3c5
@ -247,7 +247,7 @@ class SimpleClientRelay(
|
||||
|
||||
// if this is the OK of an auth event, renew all subscriptions and resend all outgoing events.
|
||||
if (authResponseWatcher.containsKey(msg.eventId)) {
|
||||
val wasAlreadyAuthenticated = authResponseWatcher.get(msg.eventId)
|
||||
val wasAlreadyAuthenticated = authResponseWatcher[msg.eventId]
|
||||
authResponseWatcher.put(msg.eventId, msg.success)
|
||||
if (wasAlreadyAuthenticated != true && msg.success) {
|
||||
sendEverything()
|
||||
@ -375,15 +375,10 @@ class SimpleClientRelay(
|
||||
}
|
||||
|
||||
fun sendAuth(signedEvent: RelayAuthEvent) {
|
||||
val challenge = signedEvent.challenge() ?: ""
|
||||
val challenge = signedEvent.challenge()
|
||||
|
||||
// only send replies to new challenges to avoid infinite loop:
|
||||
// 1. Auth is sent
|
||||
// 2. auth is rejected
|
||||
// 3. auth is requested
|
||||
// 4. auth is sent
|
||||
// ...
|
||||
if (!authChallengesSent.contains(challenge)) {
|
||||
if (challenge != null && challenge !in authChallengesSent) {
|
||||
authResponseWatcher[signedEvent.id] = false
|
||||
authChallengesSent.add(challenge)
|
||||
writeToSocket(AuthCmd.toJson(signedEvent))
|
||||
|
Loading…
x
Reference in New Issue
Block a user