Skip to content

Commit

Permalink
Edured-84:Use correct end points for deactivation flow and correct po…
Browse files Browse the repository at this point in the history
…st body arguments.

Ensure there isn't an infinite loop of network requests due to recomposition while screen is waiting for a VM event: we can wait for only one VM event or handle one error state at a time!
  • Loading branch information
Iulia Stana committed Apr 25, 2023
1 parent 845406e commit 7ac8c00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/src/main/kotlin/nl/eduid/di/api/EduIdApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface EduIdApi {
@POST("/mobile/tiqr/sp/send-phone-code")
suspend fun requestPhoneCode(@Body request: RequestPhoneCode): Response<Unit>

@POST("/ /mobile/tiqr/sp/deactivate-app")
suspend fun deactivateApp(@Body request: ConfirmPhoneCode): Response<Unit>
@POST("/mobile/tiqr/sp/deactivate-app")
suspend fun deactivateApp(@Body request: ConfirmDeactivationCode): Response<Unit>

@POST("/mobile/tiqr/sp/verify-phone-code")
suspend fun confirmPhoneCode(@Body request: ConfirmPhoneCode): Response<Unit>
Expand All @@ -36,7 +36,7 @@ interface EduIdApi {
@GET("/mobile/tiqr/sp/start-enrollment")
suspend fun startEnrollment(): Response<EnrollResponse>

@GET("//mobile/tiqr/sp/send-deactivation-phone-code")
@GET("/mobile/tiqr/sp/send-deactivation-phone-code")
suspend fun requestDeactivationForKnownPhone(): Response<Unit>

@GET("/mobile/api/sp/tokens")
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/kotlin/nl/eduid/di/model/EduIdModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ data class ConfirmPhoneCode(
val phoneVerification: String,
) : Parcelable

@Parcelize
@JsonClass(generateAdapter = true)
data class ConfirmDeactivationCode(
val verificationCode: String,
) : Parcelable


@Parcelize
@JsonClass(generateAdapter = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ fun HomePageNoAccountContent(
waitingForVmEvent = false
}
)
}

if (waitingForVmEvent && uiState.preEnrollCheck != null) {
} else if (waitingForVmEvent && uiState.preEnrollCheck != null) {
when (uiState.preEnrollCheck) {
PreEnrollCheck.AlreadyCompleted -> AlertDialogWithSingleButton(
title = stringResource(R.string.preenroll_check_completed_title),
Expand Down Expand Up @@ -99,14 +97,12 @@ fun HomePageNoAccountContent(
}
)
}
}
if (isAuthorizedForDataAccess && waitingForVmEvent && uiState.shouldTriggerAutomaticStartEnrollmentAfterOauth()) {
} else if (waitingForVmEvent && isAuthorizedForDataAccess && uiState.shouldTriggerAutomaticStartEnrollmentAfterOauth()) {
val currentOnStartEnrolment by rememberUpdatedState(onStartEnrolment)
LaunchedEffect(owner) {
currentOnStartEnrolment()
}
}
if (waitingForVmEvent && uiState.haveValidChallenge()) {
} else if (waitingForVmEvent && uiState.haveValidChallenge()) {
val currentGoToRegistrationPinSetup by rememberUpdatedState(goToRegistrationPinSetup)
LaunchedEffect(owner) {
currentGoToRegistrationPinSetup(uiState.currentChallenge as EnrollmentChallenge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Environment
import android.util.AtomicFile
import androidx.core.util.writeText
import nl.eduid.di.api.EduIdApi
import nl.eduid.di.model.ConfirmDeactivationCode
import nl.eduid.di.model.ConfirmPhoneCode
import nl.eduid.di.model.DeleteServiceRequest
import nl.eduid.di.model.EnrollResponse
Expand Down Expand Up @@ -251,7 +252,7 @@ class PersonalInfoRepository(private val eduIdApi: EduIdApi) {
}

suspend fun deactivateApp(phoneCode: String) = try {
val response = eduIdApi.deactivateApp(ConfirmPhoneCode(phoneCode))
val response = eduIdApi.deactivateApp(ConfirmDeactivationCode(phoneCode))
response.isSuccessful
} catch (e: Exception) {
Timber.e(e, "Failed to deactivate app")
Expand Down

0 comments on commit 7ac8c00

Please sign in to comment.