Skip to content

Commit

Permalink
Surface the last-used password first in autofill prompt when filling …
Browse files Browse the repository at this point in the history
…passwords (#2431)

Task/Issue URL: https://app.asana.com/0/72649045549333/1206560791755503/f
Tech Design URL:
CC:

Description:
Adds last-used as a field for saved credentials so that it can used in the sort order when presenting a list of passwords to autofill into a form.
  • Loading branch information
amddg44 authored Mar 20, 2024
1 parent 234e2d5 commit f905db6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14109,7 +14109,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 127.0.0;
version = 127.1.0;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "a693511191833453c0469e073c7090dd4a192a74",
"version" : "127.0.0"
"revision" : "05e3446229ce43733bdacb3e34ed4a1af011003c",
"version" : "127.1.0"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ extension ContentOverlayViewController: SecureVaultManagerDelegate {
promptUserToAutofillCredentialsForDomain domain: String,
withAccounts accounts: [SecureVaultModels.WebsiteAccount],
withTrigger trigger: AutofillUserScript.GetTriggerType,
onAccountSelected account: @escaping (SecureVaultModels.WebsiteAccount?) -> Void,
completionHandler: @escaping (SecureVaultModels.WebsiteAccount?) -> Void) {
// no-op on macOS
}
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ extension AutofillTabExtension: SecureVaultManagerDelegate {
promptUserToAutofillCredentialsForDomain domain: String,
withAccounts accounts: [SecureVaultModels.WebsiteAccount],
withTrigger trigger: AutofillUserScript.GetTriggerType,
onAccountSelected account: @escaping (SecureVaultModels.WebsiteAccount?) -> Void,
completionHandler: @escaping (SecureVaultModels.WebsiteAccount?) -> Void) {
// no-op on macOS
}
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.1.0"),
.package(path: "../PixelKit"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
.library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.1.0"),
.package(path: "../XPCHelper"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../LoginItems"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "127.1.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
12 changes: 12 additions & 0 deletions UnitTests/DataExport/MockSecureVault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ final class MockSecureVault<T: AutofillDatabaseProvider>: AutofillSecureVault {
return accountID
}

func updateLastUsedFor(accountId: Int64) throws {
if var account = storedAccounts.first(where: { $0.id == String(accountId) }) {
account.lastUsed = Date()
}
}

func deleteWebsiteCredentialsFor(accountId: Int64) throws {
storedCredentials[accountId] = nil
}
Expand Down Expand Up @@ -298,6 +304,12 @@ class MockDatabaseProvider: AutofillDatabaseProvider {
return _accounts
}

func updateLastUsedForAccountId(_ accountId: Int64) throws {
if var account = _accounts.first(where: { $0.id == String(accountId) }) {
account.lastUsed = Date()
}
}

func deleteWebsiteCredentialsForAccountId(_ accountId: Int64) throws {
self._accounts = self._accounts.filter { $0.id != String(accountId) }
}
Expand Down

0 comments on commit f905db6

Please sign in to comment.