I just implemented the Auth API for my application. How can I ensure users stay on the same page after a page refresh, even if they’re already authenticated?
@harman_singh, please look into this query.
which page you want user to stay on?
Can you explain your query a bit more?
Hi @Ravi_Raj,
To achieve this functionality in vDesigner 2.0, please follow these steps:
-
Save Data on Page Elements: Ensure that data is saved on all page elements, so it persists even if the page is refreshed.
-
Maintain User’s Page: When a user refreshes the page, they should remain on the same page they were on, instead of being redirected elsewhere.
-
Set Up Flags for Navigation: Use a flag on the home page to track which of the three pages the user is on. For instance:
-
When the user navigates to page 1, set the flag value to 1.
-
When the user navigates to page 2, set the flag value to 2.
-
When the user navigates to page 3, set the flag value to 3.
-
Implement Business Rule (BR): Create a business rule that checks the flag’s value. When the page is refreshed, this rule should ensure the user is redirected back to the page indicated by the flag value, rather than the home page.
@Ravi_Raj elaborating @AnushkaGupta’s points below:
Save Data Task Mapping
- Map Events:
-
After logging in, map the “Save Data” task to screen elements.
-
For example, map the “onTextChanged” event of an InputField to “Save Data” to save user input to a Business Entity.
-
Create a Business Entity with the necessary keys/attributes and link it to the element’s entity path.
Maintaining the User Journey
- Set Flags:
- Use a Business Entity with a key/attribute as a ‘flag’ (e.g., “Page_1”) to track the user’s journey.
- Page Setup:
- On each page, set up the “onPageCreate” event.
- Create a Task Group with a Copy Data task to set the flag value.
- Login Page Setup:
- On the login page, set up an “onPageCreate” event.
- Create a Task Group with multiple ‘Navigate’ tasks to handle different parts of the user’s journey.
- Add Business Rules:
-
Add “Business Rules” (BRs) to the navigation tasks to check the flag value.
-
This ensures the user is taken to the correct page based on their journey.
Keep User State:
- If the browser is refreshed, the login page checks for ‘AUTH.’
- If AUTH is successful, the user is redirected to their last visited page using navigate tasks and BRs.
This approach ensures data is saved correctly and the user’s journey is maintained, even if the browser is refreshed.