Added the catalogue models and seed to support phase 6 of the POC prototype in the Persistence package.
This commit is contained in:
1 parent
31d2d98d49
commit
256d22df40
10 files changed
+473
-4
No files matched your search
@@ -133,6 +133,27 @@ public struct AccountRepository: Sendable {
|
||||
).save(on: fluent.db())
|
||||
}
|
||||
|
||||
/// Replaces every passkey of an account with a new one: what recovering an account comes down to.
|
||||
public func replacePasskeys(
|
||||
of user: User,
|
||||
credentialID: String,
|
||||
publicKey: [UInt8],
|
||||
signCount: UInt32
|
||||
) async throws {
|
||||
try await fluent.db().transaction { database in
|
||||
try await PasskeyRecord.query(on: database)
|
||||
.filter(\.$user.$id == user.id)
|
||||
.delete()
|
||||
try await PasskeyRecord(
|
||||
userID: user.id,
|
||||
credentialID: credentialID,
|
||||
publicKey: publicKey,
|
||||
signCount: signCount,
|
||||
at: .init()
|
||||
).save(on: database)
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetches the passkeys registered to an account, the oldest first, with when each was created.
|
||||
public func passkeys(
|
||||
of user: User
|
||||
|
||||
Reference in new issue
Block a user