Skip to content
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’ll 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

Conversation

MattLichtenstein
Copy link
Collaborator

@MattLichtenstein MattLichtenstein commented Jun 24, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

Although not possible to create directly from Firefox for iOS, it is possible that saved logins with empty username fields can be synced over (i.e. via desktop). To manage this, we will still show synced username-less logins in the logins list (settings -> passwords), but will conditionally hide them from the login autofill sheet that is presented when attempting to autofill a login. The UX changes are as follows:

  • Username-less logins WILL NOT appear in the list of logins in the login autofill sheet if the sheet is accessed via the username field
    • Conversely, username-less logins WILL appear in the list when accessed via the password field (no change), and will now report (no username) above the ******** password mark instead of the URL hostname
  • The Used saved password accessory view button will no longer appear above the system keyboard when a username field gains first responder unless there are saved logins that contain a username

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

- Only hides the login when accessing the LoginAutofillView from the username html field
- Also hides the "Use saved password" button from the accessory view when selecting a username html field and there are no logins for the host URL with a username
@@ -40,6 +43,7 @@ class LoginListViewModel: ObservableObject {
do {
let logins = try await loginStorage.listLogins()
self.logins = logins.filter { login in
if field == FocusFieldType.username && login.decryptedUsername.isEmpty { return false }
Copy link
Collaborator Author

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 commit

Copy link
Collaborator Author

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

Copy link
Contributor

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?

Copy link
Contributor

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.

@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Jun 24, 2024

Messages
📖 Project coverage: 31.82%
📖 Edited 13 files
📖 Created 0 files

Client.app: Coverage: 30.43

File Coverage
BrowserViewController.swift 5.3% ⚠️
BrowserCoordinator.swift 78.41%
LoginListView.swift 71.08%
BrowserNavigationHandler.swift 100.0%
LoginListViewModel.swift 71.11%
CredentialAutofillCoordinator.swift 76.9%
LoginCellView.swift 0.0% ⚠️
LoginAutofillView.swift 98.04%

Generated by 🚫 Danger Swift against f5947a9

@@ -40,6 +43,7 @@ class LoginListViewModel: ObservableObject {
do {
let logins = try await loginStorage.listLogins()
self.logins = logins.filter { login in
if field == FocusFieldType.username && login.decryptedUsername.isEmpty { return false }
Copy link
Contributor

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?

@@ -2792,14 +2793,17 @@ extension BrowserViewController: LegacyTabDelegate {
method: .view,
object: .loginsAutofillPromptShown
)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The 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 if !loginsForCurrentTab.isEmpty, check if loginsForCurrentTab.isEmpty first. Basically the if would be switched around.

@nbhasin2
Copy link
Contributor

@MattLichtenstein :shipit:

@MattLichtenstein MattLichtenstein merged commit 0ab20e7 into main Jun 27, 2024
10 checks passed
@MattLichtenstein MattLichtenstein deleted the ml/FXIOS-9190_Hide-Usernameless-Logins-From-Autofill branch June 27, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants