TrustToken ignored when changing password by loginId
TrustToken ignored when changing password by loginId
Description
Whenever I want to change the password using the loginId, currentPassword, password and a trustToken* with mfa enabled on the respective user. The api returns status 400 with error:
"code": "[TrustTokenRequired]"
"message": "This request requires a Trust Token. Use the Start Two-Factor API to obtain a Trust Token required to complete this request."
But the trust token has been supplied in the request.
*obtained from POST /api/login followed by POST /api/two-factor/login or POST /api/two-factor/start followed by POST /api/two-factor/login
Affects versions
As far as I know only on 1.36.4 since that's the current version I'm using right now.
Steps to reproduce
Steps to reproduce the behavior:
Create a user and enable mfa
- Create a user.
- Enable mfa on the user.
Obtain a twoFactorId. There are 2 methods:
-
Method 1:
- Hit
POST /api/loginwith login credentials. This will return status242and the response will contain atwoFactorId. - Store the
twoFactorId.
-
Method 2:
- Hit
POST /api/two-factor/startwith the user'suserIdin the response body. This will return status200and the response will contain atwoFactorId. - Store the
twoFactorId.
Continue from method 1 or 2:
- Hit
POST /api/two-factor/loginwith a valid mfacodeand thetwoFactorIdfrom the previous request. This will return status200and the response will contain atrustToken. - Store the
trustToken. - Hit
POST /api/user/change-passwordwith the user'sloginId,currentPassword,passwordand with the storedtrustTokenfrom before. - The API will return status
400and contains an errorResponse with 1 error with code[TrustTokenRequired].
Expected behavior
Either the password to be changed and return a status 200 or a status 400 containing an error telling me the trustToken is invalid since it is present.
Screenshots
POST /api/two-factor/start

POST /api/two-factor/login

POST /api/user/change-password

Platform
- Device: Desktop
- OS: Windows 10 Pro
- Mozilla Firefox Developer Edition 105.0 Beta 9 (20220908185813)
- Database MySQL 8.0.23
Community guidelines
All issues filed in this repository must abide by the FusionAuth community guidelines.
Additional context
The steenshots are from Hoppscotch (similar to Postman). But the api gives the same result when using the FusionAuth php client with ->withTenantId($tenantId).
Thanks for the detailed repro steps, @timyourivh ! We'll have to take a look and see if we can reproduce on the latest version.
Internal
- https://github.com/FusionAuth/fusionauth-app/pull/172