Libki / libki-server

Libki Server
Other
55 stars 28 forks source link

Checks for redirect to login in ajax calls and reload page accordingly #235

Closed maryse-simard closed 2 years ago

maryse-simard commented 2 years ago

When a user is connected to the administration interface, they will be redirected automatically to the login screen upon visiting a new page if their session expires. However, if the user doesn't navigate away from the page they won't be redirected, which can be problematic for asynchronous javascript.

In most cases, this is not critical (datatables stuck on "Processing..." or vague error messages), but in some cases it can cause problems. For example, when updating settings in Administration/Settings the ajax succeeds (the redirection to the login page returns a success) and the "settings updated" message is shown, which is wrong.

This adds a check to ajax calls to test if returned data is html (more specifically the login form) and reloads to page, which will then cause a redirect to the login.