Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eponymous's avatar

Getting "two_factor: false" when attempting to log in

Hi, I'm using Fortify to the handle the log in for my SPA. I'm also using Sanctum to manage API tokens.

When I try to log in via Postman, I get the following response: { "two_factor": false }, and the user isn't logged in. I take this to mean that two factor authentication has failed (please correct me if I'm wrong). However I have not enabled two factor authentication in Fortify - it is commented out in the features array in the Fortify config.

So what could be causing this response?

Thanks

0 likes
4 replies
Sinnbeck's avatar

Does your user model have the TwoFactorAuthenticatable trait?

eponymous's avatar

@Sinnbeck Thanks for your reply.

No, the User model does not have the TwoFactorAuthenticatable trait. The traits it has are HasApiTokens, HasFactory, and Notifiable.

eponymous's avatar

Upon reading the documentation (again). I realize that this json response isn't indicating what I thought it was. From the Fortify docs:

"Authenticating With Two Factor Authentication

During the authentication process, Fortify will automatically redirect the user to your application's two factor authentication challenge screen. However, if your application is making an XHR login request, the JSON response returned after a successful authentication attempt will contain a JSON object that has a two_factor boolean property. You should inspect this value to know whether you should redirect to your application's two factor authentication challenge screen."

So the response { "two_factor": false } is saying that the app should not redirect to a two factor authentication screen.

TVS's avatar

What is the possible solution for this for SPA?

Please or to participate in this conversation.