When you log in to the reference application, it tries to intelligently redirect you to the last page someone was at, but this feature is implemented badly, and has led to lots of complaints.
See these tickets for examples of complaints about the current behavior:
RA-306, RA-267, RA-544, RA-975.
To improve this behavior, we will significantly limit the times where the user is redirected back to the "referrer" page.
- If I go to the URL of the login screen (or the home screen if I'm not logged in), and then log in, I should see the Home Screen
- If I go to the URL of the login screen with an explicit "?redirectUrl=..." and this URL is within the OpenMRS application, and I log in, then I should be taken to the requested URL
- If I am logged into the system, then I click Logout, and then log in as the same user, I should be taken to the Home Screen (not the page that I clicked "logout" from)
- If I am not logged into the system, and I click on a link to a page within the system (e.g. a bookmark or a link in an email), when I log in I should be taken to the page I was trying to visit.
- If I am viewing an page in the system, and my session times out, and then I click on a link and am shown the login page, and then a different user logs in, they be taken to the home screen.
- If I am viewing an page in the system, and my session times out, and then I click on a link and am shown the login page, if I log back in as the same user I should see the page I was last on.
The relevant code is in LoginPageController.java in the Reference Application module.
Currently, there is some logic that uses the "referrer", e.g. which page you came to this page from. I think this causes more problems than it solves, and my suggestion is to avoid using the page referrer if at all possible. (Maybe there is some other way to catch the scenario when the user tries to visit a page but their session is expired.)
Be sure to set up a nice suite of unit tests for this, and to remove any existing tests whose behavior is invalidated by the work in this ticket.
Further, be sure to update any code comments to make sure they reflect the new behavior.