# How to control MFA with Gatsby.js and auth0-react?

**URL:** <https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899>\
**Category:** Get Help\
**Tags:** gatsbyjs, mfa, auth0\
**Created:** [June 23, 2021, 5:53am UTC](https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899 "2021-06-23T05:53:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 23, 2021, 5:53am UTC](https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899/1 "2021-06-23T05:53:31Z")

</div>

1.I refer to this document to protect routes

> **[Auth0 React SDK for Single Page Apps](https://auth0.com/docs/libraries/auth0-react#protect-a-route)**
>
> Describes the Auth0 SDK for React Single Page Apps

2.I enable MFA with always

 ![image](https://global.discourse-cdn.com/auth0/original/3X/3/c/3cac3ebc621b2657fadd0c538ef22603bc758e25.png)  
3. I refresh the protected page after login ,I saw this request everytime.  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/e/5e5b6bce57621d849af5fb354020b3ba165a50d7.png)  
4. And I will be redirect to MFA page when I refresh page after login  
and this is my question  
1.If I enable MFA with always,I need enter OTP everytime ,when refresh protect page?  
2,if I only want to ask MFA when login not for refresh protect page,what can I do?

---

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 29, 2021, 7:31am UTC](https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899/2 "2021-06-29T07:31:19Z")

</div>

1.switch config to never

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/a/aaabae0c6d54248fe3da891827fa39051309cb01.png)  
2.use this rule

> <https://github.com/auth0/rules/blob/master/src/rules/require-mfa-once-per-session.js>

---

<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:** [June 29, 2021, 9:38am UTC](https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899/3 "2021-06-29T09:38:10Z")

</div>

Thanks for sharing it with the rest of community!

---

<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:** [July 14, 2021, 9:38am UTC](https://community.auth0.com/t/how-to-control-mfa-with-gatsby-js-and-auth0-react/64899/4 "2021-07-14T09:38:33Z")

</div>

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