metamask-mobile
metamask-mobile copied to clipboard
[IMPROVEMENT] Refactor authentication logic
Description
We need to refactor our authentication logic to make it more robust and testable. Currently, much of the auth check logic lives in the Login screen, which requires the Login screen to be mounted for the app to work (should be the other way around). Some redundant logic also exists around initial auth check vs login CTA, which we will consolidate in the refactor. Proposal is to pull out auth business logic into an AuthService, which will handle auth between app states + expose log in and log out logic for any components to consume. Refer to ReviewManager.ts.ts as an existing example of how this will be architected.
Technical Details
- Pull authentication logic from
Login.jsto new service namedAuthService.ts - May have to handle auth status between app states through use of
AppStatemodule - Replace all instances listed below to use functions from
AuthService.ts- onboarding (create account)
- onboarding (import account)
- log in
- log out
- change login methods(remember me, biometric)
- change password
- Initialize
AuthService, either inRootorAppfile - TBD: Mock AuthService for test cases?
Acceptance Criteria
-
Usual login test cases with and without biometrics
- Include biometric (fingerprint) being present, but disabled in app level settings. Toggle
Sign in with Biometricsto OFF andSign in with device PINto ON. Ensure that fingerprint does NOT grant access.
- Include biometric (fingerprint) being present, but disabled in app level settings. Toggle
-
Metrics to add to user profile properties:
- ‘Remember Me’ setting: ON or OFF
- ‘Biometrics’ setting: ON or OFF
- ‘Password’ set: YES or NO
Hey team! Please add your planning poker estimate with ZenHub @blackdevelopa @cortisiko
Added additional acceptance criteria around disabling biometric and enabling device pin.
Closing, PRs have been merged.