# MFA with OTP does not work properly when unchecking "Remember this device for 30 days"

**URL:** <https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315>\
**Category:** Get Help\
**Created:** [December 22, 2021, 7:42am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315 "2021-12-22T07:42:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenta-endo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenta-endo/32/33960_2.png) [@kenta-endo](https://community.auth0.com/u/kenta-endo)\
**Post date:** [December 22, 2021, 7:42am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/1 "2021-12-22T07:42:36Z")

</div>

We have been using MFA along with default settings (so set allowRememberBrowser to false ).  
It worked fine at the time, but to input OTP every time would be a hassle for users,  
so we try setting it to `allowRememberBrowser: true`.

The authentication succeeds if checking “Remember this device for 30 days” in the OTP screen.  
However, if unchecking it, user cannot be authenticated. (We got “isAuthenticated = false” in our code with auth0-react after redirecting to our application.)

I tried the setting back to `allowRememberBrowser: false`, but the same problem occurred. (In other words, it doesn’t work properly until checking “Remember this device for 30 days”, so we have to set allowRememberBrowser to true).

I can’t figure out what the problem is.  
How do we fix this?

library version:  
auth0-react: 1.5.0

---

<div class="post-metadata">

**Author:** ![pedro.vicente](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pedro.vicente/32/38424_2.png) [@pedro.vicente](https://community.auth0.com/u/pedro.vicente)\
**Post date:** [June 28, 2022, 2:11pm UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/2 "2022-06-28T14:11:38Z")

</div>

I’ve found the same behaviour and we can’t log in with MFA unless we check “Remember this device for 30 days", otherwise login with MFA doesn’t work and send you back to the login page.

This issue has been open since Dec’21, do you have any update or how to fix it?

---

<div class="post-metadata">

**Author:** ![JanBlaha](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/janblaha/32/23899_2.png) [@JanBlaha](https://community.auth0.com/u/JanBlaha)\
**Post date:** [July 3, 2022, 2:26pm UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/3 "2022-07-03T14:26:27Z")

</div>

I have observed the same issue.

Currently using auth0-react: 1.9.0 with react 18.2.0;  
I have a React app with an Auth0 login management using only Google Workspace connection. 2FA is currently enforced (email or authenticator). When the ‘remember’ checkbox is left unchecked on login, the user is redirected back to login after what seems of about 0.5 sec of being logged in. This loop persists until the checkbox is checked at which point the app starts behaving as expected.

---

<div class="post-metadata">

**Author:** ![nathan.jenkins](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nathan.jenkins/32/44577_2.png) [@nathan.jenkins](https://community.auth0.com/u/nathan.jenkins)\
**Post date:** [July 8, 2022, 1:48pm UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/4 "2022-07-08T13:48:44Z")

</div>

Hi all,

I believe this question has been answered on another [thread here](https://community.auth0.com/t/failed-silent-auth-multifactor-authentication-required-error/46923).

Go to your Auth0 tenant dashboard, MFA options, select “Never” instead of “Always”  
Let us know if that resolves your issue.

---

<div class="post-metadata">

**Author:** ![ben19](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben19/32/40645_2.png) [@ben19](https://community.auth0.com/u/ben19)\
**Post date:** [October 17, 2022, 3:34pm UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/5 "2022-10-17T15:34:32Z")

</div>

I have Never selected and still have a loop where I have to continuously enter a new OTP but never login

---

<div class="post-metadata">

**Author:** ![zeebhombal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zeebhombal/32/41114_2.png) [@zeebhombal](https://community.auth0.com/u/zeebhombal)\
**Post date:** [November 7, 2022, 8:17am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/6 "2022-11-07T08:17:27Z")

</div>

How is that a solution? If I require users to have 2FA enabled does that mean they will constantly be logged out unless they choose the option to ‘Remember device for 30 days’ ?  
That doesn’t really make it an _option_ then does it?

---

<div class="post-metadata">

**Author:** ![idankrayon](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/idankrayon/32/39447_2.png) [@idankrayon](https://community.auth0.com/u/idankrayon)\
**Post date:** [November 8, 2022, 2:40pm UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/7 "2022-11-08T14:40:34Z")

</div>

@nathan.jenkins do we a solution for this? Shutting the 2FA/MFA off is not a solution at all.

---

<div class="post-metadata">

**Author:** ![janson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/janson/32/12805_2.png) [@janson](https://community.auth0.com/u/janson)\
**Post date:** [May 9, 2023, 6:33am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/8 "2023-05-09T06:33:15Z")

</div>

I was running into the infinite loop issue until I added the `completedMfa` check, as I gleaned from the [thread’s OP](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/4)

```auto
function multifactorAuthentication(user, context, callback) {
  if (user.app_metadata.enforce_mfa) {
    if (context.protocol === "oauth2-refresh-token") {
      return callback(null, user, context);
    }

    const completedMfa = !!context.authentication.methods.find(
      (method) => method.name === "mfa"
    );

    if (completedMfa) {
      return callback(null, user, context);
    }

    context.multifactor = {
      provider: "any",
    };
  }

  callback(null, user, context);
}

```

Hope this helps others who ran into a similar issue.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 9, 2023, 10:35am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/9 "2023-05-09T10:35:04Z")

</div>

Thanks a lot for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![idankrayon](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/idankrayon/32/39447_2.png) [@idankrayon](https://community.auth0.com/u/idankrayon)\
**Post date:** [May 9, 2023, 11:17am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/10 "2023-05-09T11:17:33Z")

</div>

Thanks @janson i will try that out!.  
Appreciate this

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 23, 2023, 11:17am UTC](https://community.auth0.com/t/mfa-with-otp-does-not-work-properly-when-unchecking-remember-this-device-for-30-days/75315/11 "2023-05-23T11:17:51Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
