mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
feat: OTP tag #2122
This commit is contained in:
@@ -40,6 +40,7 @@ object OtpEntryFields {
|
||||
|
||||
// Field from KeePassXC
|
||||
private const val OTP_FIELD = "otp"
|
||||
private const val OTP_TAG = "OTP"
|
||||
|
||||
// URL parameters (https://github.com/google/google-authenticator/wiki/Key-Uri-Format)
|
||||
private const val OTP_SCHEME = "otpauth"
|
||||
@@ -438,13 +439,14 @@ object OtpEntryFields {
|
||||
fun EntryInfo.setOtp(otpString: String): Boolean {
|
||||
// Replace the OTP field
|
||||
parseOTPUri(otpString)?.let { otpElement ->
|
||||
tags.put(OTP_TAG)
|
||||
if (title.isEmpty())
|
||||
title = otpElement.issuer
|
||||
if (username.isEmpty())
|
||||
username = otpElement.name
|
||||
// Add OTP field
|
||||
val mutableCustomFields = customFields as ArrayList<Field>
|
||||
val otpField = OtpEntryFields.buildOtpField(otpElement, null, null)
|
||||
val otpField = buildOtpField(otpElement, null, null)
|
||||
if (mutableCustomFields.contains(otpField)) {
|
||||
mutableCustomFields.remove(otpField)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user