8000 PM-14585: Removed lock account option from Profile switcher if account has no master password by ezimet-livefront · Pull Request #1155 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PM-14585: Removed lock account option from Profile switcher if account has no master password #1155

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

Merged
merged 5 commits into from
Nov 22, 2024

Conversation

ezimet-livefront
Copy link
Collaborator
@ezimet-livefront ezimet-livefront commented Nov 21, 2024

🎟️ Tracking

PM-14585

📔 Objective

  • Added canBeLocked property for ProfileSwitcherItem.
  • Added check for canBeLockedin AuthRepository, An account can now be locked only if it has a master password, biometric authentication, or a PIN.
  • Added unit tests.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@ezimet-livefront ezimet-livefront changed the title Pm 14585/account switcher option PM-14585: Removed lock account option from Profile switcher if account has no master password Nov 21, 2024
Copy link
codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.38%. Comparing base (b4e7b5a) to head (637edfc).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...Shared/Core/Auth/Repositories/AuthRepository.swift 89.28% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1155      +/-   ##
==========================================
- Coverage   89.38%   89.38%   -0.01%     
==========================================
  Files         688      688              
  Lines       43734    43760      +26     
==========================================
+ Hits        39091    39114      +23     
- Misses       4643     4646       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor
github-actions bot commented Nov 21, 2024

Logo
Checkmarx One – Scan Summary & Details0cb4b21f-97fa-4b61-9c26-ad033968f877

No New Or Fixed Issues Found

Comment on lines 963 to 972
let hasMasterPassword: Bool = await (
try? stateService.getUserHasMasterPassword(userId: account.profile.userId)
) ?? false
let isUnlockWithPinOn: Bool = await (
try? stateService.pinProtectedUserKey(userId: account.profile.userId)
) != nil
let isUnlockWithBiometricOn: Bool = await (
try? biometricsRepository.getBiometricUnlockStatus().isEnabled
) ?? false
let canBeLocked = hasMasterPassword || isUnlockWithPinOn || isUnlockWithBiometricOn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Does it make sense to extract this logic into a func in this repository? So it's easier to be reused if needed elsewhere. It can be private for the time being if you want. What do you think?
🤔 Additionally, I see these functions already being used which is alike the logic you have here but without the user id:

  • isPinUnlockAvailable()
  • canVerifyMasterPassword()
    Would it make sense to improve these functions passing userId: String? and having an extension method with no parameter that passes userId: nil so we reuse them in this logic as well?
    I feel like by reusing these functions, then if the state service changes somehow it would be less code to maintain/update.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is good improvement, I am sure we would need this canBeLocked check somewhere else. I will add it.

@ezimet-livefront ezimet-livefront merged commit e4efd6c into main Nov 22, 2024
9 checks passed
@ezimet-livefront ezimet-livefront deleted the PM-14585/account-switcher-option branch November 22, 2024 20:54
Comment on lines +502 to +511
let hasMasterPassword: Bool = await (
try? canVerifyMasterPassword(userId: userId)
) ?? false
let isUnlockWithPinOn: Bool = await (
try? isPinUnlockAvailable(userId: userId)
) ?? false
let isUnlockWithBiometricOn: Bool = await (
try? biometricsRepository.getBiometricUnlockStatus().isEnabled
) ?? false
return hasMasterPassword || isUnlockWithPinOn || isUnlockWithBiometricOn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ @ezimet-livefront @matt-livefront IMO all the try? should not ignore errors. If errors are thrown here they should be inside a do...catch and logged into Crashlytics so we actually know something went wrong. If any of the errors should be ignored then we should have specific catch clauses for them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to add this in my future PR.

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.

3 participants
0