WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 86e534b

Browse files
authored
Fix deserialization for app credential model (#68)
1 parent 2680539 commit 86e534b

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

module/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pomGroup=com.authsignal
22
pomPackaging=aar
33
pomName=Authsignal SDK for Android
44
pomArtifactId=authsignal-android
5-
versionName=3.0.0-alpha
5+
versionName=3.0.1

module/src/main/java/com/authsignal/inapp/api/InAppAPI.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ class InAppAPI(tenantID: String, private val baseURL: String) {
4040
}
4141

4242
if (response.status == HttpStatusCode.OK) {
43-
val data = response.body<AppCredential>()
43+
val data = response.body<AppCredentialResponse>()
4444

45-
AuthsignalResponse(data = data)
45+
val credential = AppCredential(
46+
userId = data.userId,
47+
credentialId = data.userAuthenticatorId,
48+
createdAt = data.verifiedAt,
49+
lastAuthenticatedAt = data.lastVerifiedAt,
50+
)
51+
52+
AuthsignalResponse(data = credential)
4653
} else {
4754
APIError.mapToErrorResponse(response)
4855
}
@@ -73,9 +80,16 @@ class InAppAPI(tenantID: String, private val baseURL: String) {
7380
}
7481

7582
if (response.status == HttpStatusCode.OK) {
76-
val data = response.body<AppCredential>()
83+
val data = response.body<AppCredentialResponse>()
7784

78-
AuthsignalResponse(data = data)
85+
val credential = AppCredential(
86+
userId = data.userId,
87+
credentialId = data.userAuthenticatorId,
88+
createdAt = data.verifiedAt,
89+
lastAuthenticatedAt = data.lastVerifiedAt,
90+
)
91+
92+
AuthsignalResponse(data = credential)
7993
} else {
8094
APIError.mapToErrorResponse(response)
8195
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.authsignal.models.api
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
data class AppCredentialResponse(
7+
val userAuthenticatorId: String,
8+
val userId: String,
9+
val verifiedAt: String,
10+
val lastVerifiedAt: String? = null,
11+
)

module/src/main/java/com/authsignal/push/api/PushAPI.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ class PushAPI(tenantID: String, private val baseURL: String) {
3737
}
3838

3939
if (response.status == HttpStatusCode.OK) {
40-
val data = response.body<AppCredential>()
40+
val data = response.body<AppCredentialResponse>()
4141

42-
AuthsignalResponse(data = data)
42+
val credential = AppCredential(
43+
userId = data.userId,
44+
credentialId = data.userAuthenticatorId,
45+
createdAt = data.verifiedAt,
46+
lastAuthenticatedAt = data.lastVerifiedAt,
47+
)
48+
49+
AuthsignalResponse(data = credential)
4350
} else {
4451
APIError.mapToErrorResponse(response)
4552
}
@@ -70,9 +77,16 @@ class PushAPI(tenantID: String, private val baseURL: String) {
7077
}
7178

7279
if (response.status == HttpStatusCode.OK) {
73-
val data = response.body<AppCredential>()
80+
val data = response.body<AppCredentialResponse>()
81+
82+
val credential = AppCredential(
83+
userId = data.userId,
84+
credentialId = data.userAuthenticatorId,
85+
createdAt = data.verifiedAt,
86+
lastAuthenticatedAt = data.lastVerifiedAt,
87+
)
7488

75-
AuthsignalResponse(data = data)
89+
AuthsignalResponse(data = credential)
7690
} else {
7791
APIError.mapToErrorResponse(response)
7892
}

module/src/main/java/com/authsignal/qr/api/QRCodeAPI.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ class QRCodeAPI(tenantID: String, private val baseURL: String) {
4040
}
4141

4242
if (response.status == HttpStatusCode.OK) {
43-
val data = response.body<AppCredential>()
43+
val data = response.body<AppCredentialResponse>()
4444

45-
AuthsignalResponse(data = data)
45+
val credential = AppCredential(
46+
userId = data.userId,
47+
credentialId = data.userAuthenticatorId,
48+
createdAt = data.verifiedAt,
49+
lastAuthenticatedAt = data.lastVerifiedAt,
50+
)
51+
52+
AuthsignalResponse(data = credential)
4653
} else {
4754
APIError.mapToErrorResponse(response)
4855
}
@@ -73,9 +80,16 @@ class QRCodeAPI(tenantID: String, private val baseURL: String) {
7380
}
7481

7582
if (response.status == HttpStatusCode.OK) {
76-
val data = response.body<AppCredential>()
83+
val data = response.body<AppCredentialResponse>()
7784

78-
AuthsignalResponse(data = data)
85+
val credential = AppCredential(
86+
userId = data.userId,
87+
credentialId = data.userAuthenticatorId,
88+
createdAt = data.verifiedAt,
89+
lastAuthenticatedAt = data.lastVerifiedAt,
90+
)
91+
92+
AuthsignalResponse(data = credential)
7993
} else {
8094
APIError.mapToErrorResponse(response)
8195
}

0 commit comments

Comments
 (0)