Skip to content

Commit

Permalink
Merge pull request #30 from HedvigInsurance/feature/remove-old-token-…
Browse files Browse the repository at this point in the history
…migration

Remove "migrateFromOldToken"
  • Loading branch information
StylianosGakis authored Feb 29, 2024
2 parents 8cd1f4d + 24a6e73 commit e10e343
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/commonMain/kotlin/com/hedvig/authlib/AuthRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public interface AuthRepository {
public suspend fun exchange(grant: Grant): AuthTokenResult

public suspend fun revoke(token: String): RevokeResult

public suspend fun migrateOldToken(token: String): AuthTokenResult
}

@Suppress("unused")
Expand Down
23 changes: 0 additions & 23 deletions src/commonMain/kotlin/com/hedvig/authlib/NetworkAuthRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.hedvig.authlib
import com.hedvig.authlib.internal.commonKtorConfiguration
import com.hedvig.authlib.network.ExchangeAuthorizationCodeRequest
import com.hedvig.authlib.network.ExchangeRefreshTokenRequest
import com.hedvig.authlib.network.MigrateOldTokenRequest
import com.hedvig.authlib.network.MigrateOldTokenResponse
import com.hedvig.authlib.network.RevokeRequest
import com.hedvig.authlib.network.SubmitOtpRequest
import com.hedvig.authlib.network.buildStartLoginRequest
Expand All @@ -14,9 +12,7 @@ import com.hedvig.authlib.network.toLoginStatusResult
import com.hedvig.authlib.network.toSubmitOtpResult
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.call.body
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.*
import io.ktor.client.request.get
import io.ktor.client.request.post
import io.ktor.client.request.setBody
Expand Down Expand Up @@ -196,23 +192,4 @@ public class NetworkAuthRepository(
RevokeResult.Error("Error: ${e.message}")
}
}

override suspend fun migrateOldToken(token: String): AuthTokenResult {
return try {
val response = ktorClient.post("${environment.gatewayUrl}/migrate-auth-token") {
contentType(ContentType.Application.Json)
setBody(MigrateOldTokenRequest(token))
}

val responseBody = response.body<MigrateOldTokenResponse>()

return exchange(AuthorizationCodeGrant(responseBody.authorizationCode))
} catch (e: CancellationException) {
throw e
} catch (e: IOException) {
AuthTokenResult.Error.IOError("IO Error with message: ${e.message ?: "unknown message"}")
} catch (e: Exception) {
AuthTokenResult.Error.UnknownError("Error: ${e.message}")
}
}
}

This file was deleted.

This file was deleted.

0 comments on commit e10e343

Please sign in to comment.