-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix FXIOS-9190 Hide username-less logins from autofill #20766
Merged
MattLichtenstein
merged 5 commits into
main
from
ml/FXIOS-9190_Hide-Usernameless-Logins-From-Autofill
Jun 27, 2024
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
692a45f
Hides Usernameless-logins from autofill sheet
MattLichtenstein 27980ce
Unit tests
MattLichtenstein e7bd60c
lint
MattLichtenstein a7085d8
Remove unit tests
MattLichtenstein f5947a9
improved control flow readability
MattLichtenstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2781,6 +2781,7 @@ extension BrowserViewController: LegacyTabDelegate { | |
guard let tabURL = tab?.url else { return } | ||
let logins = (try? await self?.profile.logins.listLogins()) ?? [] | ||
let loginsForCurrentTab = logins.filter { login in | ||
if field == FocusFieldType.username && login.decryptedUsername.isEmpty { return false } | ||
guard let recordHostnameURL = URL(string: login.hostname) else { return false } | ||
return recordHostnameURL.baseDomain == tabURL.baseDomain | ||
} | ||
|
@@ -2792,14 +2793,17 @@ extension BrowserViewController: LegacyTabDelegate { | |
method: .view, | ||
object: .loginsAutofillPromptShown | ||
) | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I learned that it's better to start with the positive case. So instead of checking for |
||
tab?.webView?.accessoryView.reloadViewFor(.standard) | ||
} | ||
tab?.webView?.accessoryView.savedLoginsClosure = { | ||
Task { @MainActor [weak self] in | ||
// Dismiss keyboard | ||
webView?.resignFirstResponder() | ||
self?.authenticateSelectSavedLoginsClosureBottomSheet( | ||
tabURL: tabURL, | ||
currentRequestId: currentRequestId | ||
currentRequestId: currentRequestId, | ||
field: field | ||
) | ||
} | ||
} | ||
|
@@ -2848,11 +2852,19 @@ extension BrowserViewController: LegacyTabDelegate { | |
tab.addContentScript(FocusHelper(tab: tab), name: FocusHelper.name()) | ||
} | ||
|
||
private func authenticateSelectSavedLoginsClosureBottomSheet(tabURL: URL, currentRequestId: String) { | ||
private func authenticateSelectSavedLoginsClosureBottomSheet( | ||
tabURL: URL, | ||
currentRequestId: String, | ||
field: FocusFieldType | ||
) { | ||
appAuthenticator.getAuthenticationState { [unowned self] state in | ||
switch state { | ||
case .deviceOwnerAuthenticated: | ||
self.navigationHandler?.showSavedLoginAutofill(tabURL: tabURL, currentRequestId: currentRequestId) | ||
self.navigationHandler?.showSavedLoginAutofill( | ||
tabURL: tabURL, | ||
currentRequestId: currentRequestId, | ||
field: field | ||
) | ||
case .deviceOwnerFailed: | ||
// Keep showing bvc | ||
break | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
EncryptedLogin.decryptedUsername
the best way to check if a login has a username? I noticed some fragility with that and keychain when trying to add tests in this commitThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the meantime, I have removed tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @nbhasin2 knows the answer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally you can check if you have decrypted logins before as keychain can be unreliable at times.
However from a quick glance its fine as we deal with per field encryption.