Problem statement
We want to test force login with max_age=0 with our react SDK. How to do it?
Solution
- Download the following sample we have to test the react SDK: Auth0 React SDK Quickstarts: Add Login to your React App
- Add two dropdown buttons in the components/NavBar.js file of the project:
a. one that forces login with max_age=0
b. another one without max_age=0
<DropdownItem
id="qsLoginBtn"
color="primary"
block
onClick={() => loginWithRedirect({max_age: 0})}>
<FontAwesomeIcon icon="power-off" className="mr-3" /> Force Login Max_Age=0
</DropdownItem>
<DropdownItem
id="qsLoginBtn"
color="primary"
block
onClick={() => loginWithRedirect({})}>
<FontAwesomeIcon icon="power-off" className="mr-3" /> Force Login without Max Age
</DropdownItem>
</DropdownMenu>
-
Run the application and sign in, then click on the
ForceLogin without the Max Age
Button of the dropdown menu. it will hit the authorize endpoint without the max_age=0 parameter and it will not prompt for login, which is expected.
-
Then, click on the ForceLogin without max_age = 0 and it will successfully prompt for login → which is also expected.
By doing this, you should be able to test how to force login with max_age=0. However, we strongly recommend reading this doc to make sure you are doing the best practices for your application, as this is just for testing the behavior