mirror of
https://github.com/bitwarden/android.git
synced 2024-11-24 10:25:57 +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.ui.platform.manager.intent.IntentManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
|
@ -51,22 +50,23 @@ class Fido2ProviderProcessorImpl(
|
|||
cancellationSignal: CancellationSignal,
|
||||
callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,
|
||||
) {
|
||||
cancellationSignal.setOnCancelListener {
|
||||
callback.onError(CreateCredentialCancellationException())
|
||||
scope.cancel()
|
||||
}
|
||||
|
||||
val userId = authRepository.activeUserId
|
||||
if (userId == null) {
|
||||
callback.onError(CreateCredentialUnknownException("Active user is required."))
|
||||
return
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
val createCredentialJob = scope.launch {
|
||||
processCreateCredentialRequest(request = request)
|
||||
?.let { callback.onResult(it) }
|
||||
?: callback.onError(CreateCredentialUnknownException())
|
||||
}
|
||||
cancellationSignal.setOnCancelListener {
|
||||
if (createCredentialJob.isActive) {
|
||||
createCredentialJob.cancel()
|
||||
}
|
||||
callback.onError(CreateCredentialCancellationException())
|
||||
}
|
||||
}
|
||||
|
||||
private fun processCreateCredentialRequest(
|
||||
|
|
Loading…
Reference in a new issue