Include pending contact id in error response

This commit is contained in:
Nico Alt
2021-02-19 12:00:00 +00:00
parent d095ba0b15
commit 3e7e37f5f6
4 changed files with 10 additions and 2 deletions

View File

@@ -175,6 +175,7 @@ possible attack.
```json
{
"error": "PENDING_EXISTS",
"pendingContactId": "jsTgWcsEQ2g9rnomeK1g/hmO8M1Ix6ZIGWAjgBtlS9U=",
"pendingContactAlias": "Alice"
}
```

View File

@@ -117,8 +117,11 @@ constructor(
return ctx.json(details)
} catch (e: PendingContactExistsException) {
ctx.status(FORBIDDEN_403)
val details =
mapOf("error" to "PENDING_EXISTS", "pendingContactAlias" to e.pendingContact.alias)
val details = mapOf(
"error" to "PENDING_EXISTS",
"pendingContactId" to e.pendingContact.id.bytes,
"pendingContactAlias" to e.pendingContact.alias
)
return ctx.json(details)
}
return ctx.json(pendingContact.output())

View File

@@ -132,9 +132,12 @@ class ContactControllerIntegrationTest: IntegrationTest() {
var response = post("$url/contacts/add/pending", json)
assertEquals(200, response.statusCode)
val pendingContactId = response.jsonObject.getString("pendingContactId")
response = post("$url/contacts/add/pending", json)
assertEquals(403, response.statusCode)
assertEquals("PENDING_EXISTS", response.jsonObject.getString("error"))
assertEquals(pendingContactId, response.jsonObject.getString("pendingContactId"))
assertEquals(alias, response.jsonObject.getString("pendingContactAlias"))
}

View File

@@ -216,6 +216,7 @@ internal class ContactControllerTest : ControllerTest() {
ctx.json(
mapOf(
"error" to "PENDING_EXISTS",
"pendingContactId" to pendingContact.id.bytes,
"pendingContactAlias" to pendingContact.alias
)
)