# Auth0 React SDK: Have to login again on every page refresh if Display Organization Prompt is enabled

**URL:** <https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462>\
**Category:** Get Help\
**Tags:** organizations, react, auth0\
**Created:** [July 20, 2021, 2:27pm UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462 "2021-07-20T14:27:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric99](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eric99/32/22863_2.png) [@eric99](https://community.auth0.com/u/eric99)\
**Post date:** [July 20, 2021, 2:27pm UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/1 "2021-07-20T14:27:09Z")

</div>

Hi.

I’ve successfully implemented Auth0 with a SPA frontend using the `@auth0/auth0-react` package and when logging in as a normal user, everything is working fine. Most notably, when I do a full page refresh, I’m still logged in.

However, if I go to Applications → {My App} → Organizations and then set `What types of end-users will access this application?` to `Team members of organizations` (which is what I need for this app) and then enable `Display Organization Prompt`, a full page refresh of my website will redirect me to the Universal Login screen every time. I have enabled and disabled these options a couple of times and it’s reproducible every time.

I use the `withAuthenticationRequired` Higher Order Component function and looking at its implementation, I suspect the SDK has a bug related to the `isAuthenticated` flag in the case where the user has logged in under an organization that makes `isAuthenticated` be false and invoke `loginWithRedirect` unnecessarily.

Edit: This is my experience on localhost while developing. I haven’t tested if this behaves differently in a production setting.

---

<div class="post-metadata">

**Author:** ![supernaut](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/supernaut/32/31260_2.png) [@supernaut](https://community.auth0.com/u/supernaut)\
**Post date:** [August 25, 2021, 2:43pm UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/2 "2021-08-25T14:43:48Z")

</div>

We have this same problem in our React app. Please advise on if a solution exists, the current behavior is not acceptable in a production application.

Sincerely  
Christian Carollo

---

<div class="post-metadata">

**Author:** ![benedict.jackson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/benedict.jackson/32/13314_2.png) [@benedict.jackson](https://community.auth0.com/u/benedict.jackson)\
**Post date:** [September 8, 2021, 11:20am UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/3 "2021-09-08T11:20:30Z")

</div>

Looks like this is being worked on in the underlying auth0-spa-js library but could take some time to pass testing and for the react library to be updated.

> <https://github.com/auth0/auth0-spa-js/pull/788>
>
> Key changes:
> 
> \* If an \`org\_id\` claim is returned in the ID token, the SDK stor…es it in a new cookie to act as a "hint" for silent authentication
> \* When doing \`getTokenSilently\` with iframe + \`prompt=none\`, if the hint cookie is available and no value for \`organization\` was given in the options, the value from the cookie is read and sent to the authorization request
> \* If the hint cookie is available and \`organization\` is present in the options, the options value takes precedence
> \* The cookie is removed on logout
> \* The cookie is removed if there is no \`org\_id\` claim in the ID token
> 
> I also evolved the playground a bit so that you can toggle the organization ID being passed through constructor options or directly to \`loginWithRedirect\`. I also added JSON output at the bottom so that the options being used to initialize the SDK are visible.

---

<div class="post-metadata">

**Author:** ![adam.housman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.housman/32/19907_2.png) [@adam.housman](https://community.auth0.com/u/adam.housman)\
**Post date:** [September 16, 2021, 7:59pm UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/4 "2021-09-16T19:59:03Z")

</div>

Thanks @benedict.jackson. This was included in the [auth0-spa-js release v1.18.0](https://github.com/auth0/auth0-spa-js/releases/tag/v1.18.0), and we plan to update the React & Angular SDKs in the near future.

---

<div class="post-metadata">

**Author:** ![adam.housman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.housman/32/19907_2.png) [@adam.housman](https://community.auth0.com/u/adam.housman)\
**Post date:** [September 20, 2021, 4:47pm UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/5 "2021-09-20T16:47:54Z")

</div>

[Angular](https://github.com/auth0/auth0-angular/releases/tag/v1.7.0) and [React](https://github.com/auth0/auth0-react/releases/tag/v1.8.0) SDKs have been updated.

---

<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:** [September 30, 2021, 9:40am UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/6 "2021-09-30T09:40:09Z")

</div>

Thanks for the follow-up on that Adam!

---

<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:** [September 30, 2021, 9:40am UTC](https://community.auth0.com/t/auth0-react-sdk-have-to-login-again-on-every-page-refresh-if-display-organization-prompt-is-enabled/66462/7 "2021-09-30T09:40:12Z")

</div>


