fix: Unable to sync the cipher with a null password history last used date
This commit is contained in:
parent
b15a1dff67
commit
dee746a5bc
|
@ -10,14 +10,19 @@ data class PasswordHistoryRequest(
|
|||
@SerialName("password")
|
||||
val password: String,
|
||||
@SerialName("lastUsedDate")
|
||||
val lastUsedDate: Instant?,
|
||||
val lastUsedDate: Instant,
|
||||
)
|
||||
|
||||
fun PasswordHistoryRequest.Companion.of(
|
||||
model: BitwardenCipher.Login.PasswordHistory,
|
||||
) = kotlin.run {
|
||||
val lastUsedDate = model.lastUsedDate
|
||||
// Bitwarden forces us to have a last used date for
|
||||
// the password history item. It still allows for existing
|
||||
// items to have it as null tho.
|
||||
?: Instant.fromEpochMilliseconds(0)
|
||||
PasswordHistoryRequest(
|
||||
password = model.password,
|
||||
lastUsedDate = model.lastUsedDate,
|
||||
lastUsedDate = lastUsedDate,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -182,7 +182,11 @@ suspend fun BitwardenCipher.Login.toDomain(
|
|||
|
||||
fun BitwardenCipher.Login.PasswordHistory.toDomain() = DSecret.Login.PasswordHistory(
|
||||
password = password,
|
||||
lastUsedDate = lastUsedDate,
|
||||
// Bitwarden forces us to have a last used date for
|
||||
// the password history item. The ones that had it as
|
||||
// null will end up converted to the zero Unix timestamp.
|
||||
lastUsedDate = lastUsedDate
|
||||
?.takeUnless { it.epochSeconds == 0L },
|
||||
)
|
||||
|
||||
fun BitwardenCipher.Login.PasswordStrength.toDomain() = PasswordStrength(
|
||||
|
|
Loading…
Reference in New Issue