mirror of
https://github.com/bitwarden/android.git
synced 2024-11-28 13:58:51 +03:00
Cancel FIDO 2 registration job when cancellation occurs (#3583)
This commit is contained in:
parent
4abf907dc5
commit
7ddbc99add
1 changed files with 7 additions and 7 deletions
|
@ -25,7 +25,6 @@ import com.x8bit.bitwarden.data.auth.repository.model.UserState
|
||||||
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
||||||
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.cancel
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
|
@ -51,22 +50,23 @@ class Fido2ProviderProcessorImpl(
|
||||||
cancellationSignal: CancellationSignal,
|
cancellationSignal: CancellationSignal,
|
||||||
callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,
|
callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,
|
||||||
) {
|
) {
|
||||||
cancellationSignal.setOnCancelListener {
|
|
||||||
callback.onError(CreateCredentialCancellationException())
|
|
||||||
scope.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
val userId = authRepository.activeUserId
|
val userId = authRepository.activeUserId
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
callback.onError(CreateCredentialUnknownException("Active user is required."))
|
callback.onError(CreateCredentialUnknownException("Active user is required."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.launch {
|
val createCredentialJob = scope.launch {
|
||||||
processCreateCredentialRequest(request = request)
|
processCreateCredentialRequest(request = request)
|
||||||
?.let { callback.onResult(it) }
|
?.let { callback.onResult(it) }
|
||||||
?: callback.onError(CreateCredentialUnknownException())
|
?: callback.onError(CreateCredentialUnknownException())
|
||||||
}
|
}
|
||||||
|
cancellationSignal.setOnCancelListener {
|
||||||
|
if (createCredentialJob.isActive) {
|
||||||
|
createCredentialJob.cancel()
|
||||||
|
}
|
||||||
|
callback.onError(CreateCredentialCancellationException())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processCreateCredentialRequest(
|
private fun processCreateCredentialRequest(
|
||||||
|
|
Loading…
Reference in a new issue