Skip to content

Commit 50c2a5b

Browse files
authored
Fix regression with LCP passphrases (#542)
1 parent b603df6 commit 50c2a5b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ All notable changes to this project will be documented in this file. Take a look
1616

1717
* The `close()` and `Closeable` APIs are now deprecated. Resources are automatically released upon `deinit`, which aligns better with Swift.
1818

19+
### Fixed
20+
21+
#### LCP
22+
23+
* Fixed a regression that caused some LCP passphrases to no longer match the protected publication.
24+
1925

2026
## [3.0.0-beta.2]
2127

Sources/Adapters/LCPSQLite/SQLiteLCPPassphraseRepository.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@ public class LCPSQLitePassphraseRepository: LCPPassphraseRepository, Loggable {
4141

4242
public func passphrasesMatching(userID: User.ID?, provider: LicenseDocument.Provider) async throws -> [LCPPassphraseHash] {
4343
try logAndRethrow {
44-
try db.prepare(transactions.select(passphrase)
45-
.filter(self.userId == userID && self.provider == provider)
46-
)
47-
.compactMap { try $0.get(passphrase) }
44+
var passphrases =
45+
try db.prepare(transactions.select(passphrase)
46+
.filter(self.userId == userID && self.provider == provider)
47+
)
48+
.compactMap { try $0.get(passphrase) }
49+
50+
// The legacy SQLite database did not save all the new
51+
// (passphrase, userID, provider) tuples. So we need to fall back
52+
// on checking all the saved passphrases for a match.
53+
passphrases += try db.prepare(transactions.select(passphrase))
54+
.compactMap { try $0.get(passphrase) }
55+
56+
return passphrases
4857
}
4958
}
5059

0 commit comments

Comments
 (0)