mirror of
https://github.com/bitwarden/android.git
synced 2025-12-11 04:39:19 -06:00
Force scanned codes to uppercase alpha characters (#85)
This commit is contained in:
parent
d9e29d3c81
commit
31669cf457
@ -1,6 +1,8 @@
|
||||
package com.bitwarden.authenticator.ui.authenticator.feature.qrcodescan
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.ui.text.intl.Locale
|
||||
import androidx.compose.ui.text.toUpperCase
|
||||
import com.bitwarden.authenticator.data.authenticator.manager.TotpCodeManager
|
||||
import com.bitwarden.authenticator.data.authenticator.repository.AuthenticatorRepository
|
||||
import com.bitwarden.authenticator.data.authenticator.repository.model.TotpCodeResult
|
||||
@ -53,8 +55,12 @@ class QrCodeScanViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
val scannedCodeUri = Uri.parse(scannedCode)
|
||||
val secretValue = scannedCodeUri.getQueryParameter(TotpCodeManager.SECRET_PARAM)
|
||||
if (secretValue == null || !secretValue.isBase32()) {
|
||||
val secretValue = scannedCodeUri
|
||||
.getQueryParameter(TotpCodeManager.SECRET_PARAM)
|
||||
.orEmpty()
|
||||
.toUpperCase(Locale.current)
|
||||
|
||||
if (secretValue.isEmpty() || !secretValue.isBase32()) {
|
||||
authenticatorRepository.emitTotpCodeResult(TotpCodeResult.CodeScanningError)
|
||||
sendEvent(QrCodeScanEvent.NavigateBack)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user