Commit 6df8a92
authored
fix: biometric bug with incorrect password during rehydration (MetaMask#27900)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Seedless/OAuth rehydration was prompting biometrics with a wrong
password entry too
**Solution**
Now the flow is password-first: unlockWallet runs with password only.
After a successful unlock, post-unlock steps (including optional
biometric upgrade). Failed unlocks no longer trigger biometric prompts.
Jira: https://consensyssoftware.atlassian.net/browse/TO-600
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TO-600
## **Manual testing steps**
```gherkin
Feature: Seedless OAuth rehydration password before biometrics
Scenario: Wrong password does not trigger biometrics before unlock
Given the user is on the OAuth rehydration screen with a seedless wallet
And device biometrics are available
When the user enters an incorrect password and submits
Then the app shows an invalid password error
And the system biometric prompt is not shown before unlock fails
Scenario: Correct password offers biometrics after successful unlock (rehydration)
Given the user is on the OAuth rehydration screen
And device biometrics are available
When the user enters the correct password and submits
Then unlock completes successfully
And the app may prompt for device biometrics / keychain upgrade only after unlock succeeds
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
https://github.com/user-attachments/assets/e5ade971-0f7e-4316-b272-9f2aa7c58fb8
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the seedless/OAuth rehydration login flow and post-unlock auth
preference updates, which can affect authentication UX and keychain
storage behavior. Scope is limited to `OAuthRehydration` and
adds/adjusts tests to cover ordering and failure cases.
>
> **Overview**
> Updates `OAuthRehydration` so biometric/device-auth prompts no longer
occur *before* password verification: `unlockWallet` is called with
`currentAuthType: PASSWORD`, and an optional post-unlock step
(`upgradeKeychainAuthAfterSuccessfulUnlock`) requests device auth and
persists the result via `updateAuthPreference`.
>
> Extends `OAuthRehydration` tests to assert call ordering (unlock
precedes biometrics) and to ensure biometrics/auth-preference updates
are not triggered when password unlock fails, including the
outdated-password flow.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f0c3963. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 6fa43af commit 6df8a92
2 files changed
Lines changed: 119 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| 196 | + | |
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
| |||
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| |||
233 | 239 | | |
234 | 240 | | |
235 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
236 | 283 | | |
237 | 284 | | |
238 | 285 | | |
| |||
246 | 293 | | |
247 | 294 | | |
248 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
249 | 308 | | |
250 | 309 | | |
251 | 310 | | |
| |||
858 | 917 | | |
859 | 918 | | |
860 | 919 | | |
| 920 | + | |
861 | 921 | | |
862 | 922 | | |
863 | 923 | | |
864 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
865 | 942 | | |
866 | 943 | | |
867 | 944 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
155 | 185 | | |
156 | 186 | | |
157 | 187 | | |
| |||
485 | 515 | | |
486 | 516 | | |
487 | 517 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
| 518 | + | |
494 | 519 | | |
495 | | - | |
| 520 | + | |
496 | 521 | | |
497 | 522 | | |
498 | 523 | | |
| |||
506 | 531 | | |
507 | 532 | | |
508 | 533 | | |
| 534 | + | |
| 535 | + | |
509 | 536 | | |
510 | 537 | | |
511 | 538 | | |
| |||
542 | 569 | | |
543 | 570 | | |
544 | 571 | | |
545 | | - | |
| 572 | + | |
546 | 573 | | |
547 | 574 | | |
548 | 575 | | |
| |||
551 | 578 | | |
552 | 579 | | |
553 | 580 | | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
| 581 | + | |
560 | 582 | | |
561 | | - | |
| 583 | + | |
562 | 584 | | |
563 | 585 | | |
564 | 586 | | |
| |||
572 | 594 | | |
573 | 595 | | |
574 | 596 | | |
| 597 | + | |
| 598 | + | |
575 | 599 | | |
576 | 600 | | |
577 | 601 | | |
| |||
593 | 617 | | |
594 | 618 | | |
595 | 619 | | |
596 | | - | |
| 620 | + | |
597 | 621 | | |
598 | 622 | | |
599 | 623 | | |
| |||
0 commit comments