Commit adcb2c2
authored
chore: Update reauthenticate method with proper error (#24213)
<!--
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**
<!--
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?
-->
Update `reauthenticate` method to throw more verbose errors. For
example, when password is not set using biometrics. This also fixes an
issue where reset password screen would show the incorrect error message
when attempting to use biometrics. The correct behavior is that it
should not show incorrect message when password is not stored using
biometrics.
## **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:
## **Related issues**
Fixes: MetaMask/MetaMask-planning#6008
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/2681f8f9-b8d5-4aa7-ac8c-5daf47972520
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/19538c61-66ba-4642-be0e-6dbe5675c8fa
## **Pre-merge author checklist**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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]
> Reworks reauthentication to emit explicit
PASSWORD_NOT_SET_WITH_BIOMETRICS/BIOMETRIC_ERROR and updates UI/tests to
handle no-credentials flows without showing incorrect-password warnings.
>
> - **Authentication**:
> - Refactor `Authentication.reauthenticate` to use stored keychain
credentials; throw `PASSWORD_NOT_SET_WITH_BIOMETRICS` when absent and
wrap keychain failures as `BIOMETRIC_ERROR`.
> - Update `updateAuthPreference` to convert
`PASSWORD_NOT_SET_WITH_BIOMETRICS` into
`AUTHENTICATION_APP_TRIGGERED_AUTH_NO_CREDENTIALS` and keep lock-time
handling.
> - Add `ReauthenticateErrorType` values
(`PASSWORD_NOT_SET_WITH_BIOMETRICS`, `BIOMETRIC_ERROR`).
> - **UI**:
> - `Views/ResetPassword`: suppress incorrect-password warning when
`PASSWORD_NOT_SET_WITH_BIOMETRICS`; always resolve loading state in
`finally`.
> - `Views/RevealPrivateCredential`: suppress incorrect-password warning
on `PASSWORD_NOT_SET_WITH_BIOMETRICS`.
> - **Tests**:
> - Update tests to expect `PASSWORD_NOT_SET_WITH_BIOMETRICS`; remove
legacy `BIOMETRIC_NOT_ENABLED` expectations and related storage checks;
add mapping test to `AUTHENTICATION_APP_TRIGGERED_AUTH_NO_CREDENTIALS`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8a8b246. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent e03727e commit adcb2c2
5 files changed
Lines changed: 43 additions & 37 deletions
File tree
- app
- components/Views
- ResetPassword
- RevealPrivateCredential
- core/Authentication
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
656 | 657 | | |
657 | 658 | | |
658 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
659 | 670 | | |
660 | 671 | | |
661 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
662 | 677 | | |
663 | 678 | | |
664 | 679 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3984 | 3984 | | |
3985 | 3985 | | |
3986 | 3986 | | |
3987 | | - | |
3988 | | - | |
| 3987 | + | |
| 3988 | + | |
3989 | 3989 | | |
3990 | | - | |
| 3990 | + | |
3991 | 3991 | | |
3992 | 3992 | | |
3993 | 3993 | | |
| |||
4230 | 4230 | | |
4231 | 4231 | | |
4232 | 4232 | | |
4233 | | - | |
| 4233 | + | |
4234 | 4234 | | |
4235 | | - | |
4236 | | - | |
4237 | | - | |
4238 | 4235 | | |
4239 | 4236 | | |
4240 | 4237 | | |
4241 | 4238 | | |
4242 | 4239 | | |
4243 | | - | |
| 4240 | + | |
4244 | 4241 | | |
4245 | 4242 | | |
4246 | | - | |
4247 | | - | |
4248 | | - | |
4249 | | - | |
4250 | | - | |
4251 | | - | |
4252 | | - | |
4253 | | - | |
4254 | | - | |
4255 | | - | |
4256 | | - | |
4257 | | - | |
4258 | | - | |
4259 | | - | |
4260 | | - | |
4261 | | - | |
4262 | | - | |
4263 | 4243 | | |
4264 | | - | |
4265 | | - | |
| 4244 | + | |
4266 | 4245 | | |
4267 | 4246 | | |
4268 | 4247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
1521 | 1520 | | |
1522 | 1521 | | |
1523 | 1522 | | |
1524 | | - | |
| 1523 | + | |
1525 | 1524 | | |
1526 | 1525 | | |
1527 | 1526 | | |
1528 | | - | |
| 1527 | + | |
1529 | 1528 | | |
1530 | 1529 | | |
1531 | 1530 | | |
| |||
1571 | 1570 | | |
1572 | 1571 | | |
1573 | 1572 | | |
1574 | | - | |
1575 | | - | |
| 1573 | + | |
1576 | 1574 | | |
1577 | 1575 | | |
1578 | 1576 | | |
1579 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1580 | 1586 | | |
1581 | 1587 | | |
1582 | 1588 | | |
1583 | 1589 | | |
1584 | 1590 | | |
1585 | | - | |
| 1591 | + | |
| 1592 | + | |
1586 | 1593 | | |
1587 | | - | |
| 1594 | + | |
1588 | 1595 | | |
1589 | 1596 | | |
1590 | 1597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
0 commit comments