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")
|
@SerialName("password")
|
||||||
val password: String,
|
val password: String,
|
||||||
@SerialName("lastUsedDate")
|
@SerialName("lastUsedDate")
|
||||||
val lastUsedDate: Instant?,
|
val lastUsedDate: Instant,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun PasswordHistoryRequest.Companion.of(
|
fun PasswordHistoryRequest.Companion.of(
|
||||||
model: BitwardenCipher.Login.PasswordHistory,
|
model: BitwardenCipher.Login.PasswordHistory,
|
||||||
) = kotlin.run {
|
) = 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(
|
PasswordHistoryRequest(
|
||||||
password = model.password,
|
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(
|
fun BitwardenCipher.Login.PasswordHistory.toDomain() = DSecret.Login.PasswordHistory(
|
||||||
password = password,
|
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(
|
fun BitwardenCipher.Login.PasswordStrength.toDomain() = PasswordStrength(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user