Skip to content

Commit

Permalink
Add client header (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristhianescobar authored Sep 27, 2024
1 parent 3bf592d commit 3358bb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import io.newm.shared.internal.api.models.ResetPasswordException
import io.newm.shared.internal.api.models.ResetPasswordRequest
import io.newm.shared.internal.api.utils.addHumanVerificationCodeToHeader
import io.newm.shared.public.models.error.KMMException
import shared.getPlatformName


internal class LoginAPI(
Expand Down Expand Up @@ -63,6 +64,7 @@ internal class LoginAPI(
contentType(ContentType.Application.Json)
setBody(user)
addHumanVerificationCodeToHeader(humanVerificationCode)
parameter("clientPlatform", getPlatformName())
}
when (response.status) {
HttpStatusCode.OK -> {}
Expand All @@ -85,6 +87,7 @@ internal class LoginAPI(
contentType(ContentType.Application.Json)
setBody(user)
addHumanVerificationCodeToHeader(humanVerificationCode)
parameter("clientPlatform", getPlatformName())
}.body<LoginResponse>()

suspend fun loginWithGoogle(
Expand All @@ -95,6 +98,7 @@ internal class LoginAPI(
contentType(ContentType.Application.Json)
setBody(request)
addHumanVerificationCodeToHeader(humanVerificationCode)
parameter("clientPlatform", getPlatformName())
}

return when (response.status) {
Expand All @@ -113,6 +117,7 @@ internal class LoginAPI(
contentType(ContentType.Application.Json)
setBody(request)
addHumanVerificationCodeToHeader(humanVerificationCode)
parameter("clientPlatform", getPlatformName())
}

return when (response.status) {
Expand All @@ -127,6 +132,7 @@ internal class LoginAPI(
val response = httpClient.post("/v1/auth/login/facebook") {
contentType(ContentType.Application.Json)
setBody(request)
parameter("clientPlatform", getPlatformName())
}

return when (response.status) {
Expand All @@ -141,6 +147,7 @@ internal class LoginAPI(
val response = httpClient.post("/v1/auth/login/linkedin") {
contentType(ContentType.Application.Json)
setBody(request)
parameter("clientPlatform", getPlatformName())
}

return when (response.status) {
Expand Down
2 changes: 1 addition & 1 deletion shared/src/iosMain/kotlin/shared/actual.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ actual fun platformModule() = module {
single<TokenManager> { TokenManagerImpl(get(), get()) }
}

actual fun getPlatformName(): String = "iOS"
actual fun getPlatformName(): String = "IOS"

0 comments on commit 3358bb0

Please sign in to comment.