mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2841 from overleaf/as-fix-system-message-redirect
Fix system messages breaking when user logs out GitOrigin-RevId: 10cce5466fed407469964db7caa4628e9c0536a3
This commit is contained in:
parent
4c88a83332
commit
f159b2ee47
1 changed files with 15 additions and 2 deletions
|
@ -13,12 +13,25 @@ import App from '../base'
|
|||
const MESSAGE_POLL_INTERVAL = 15 * 60 * 1000
|
||||
// Controller for messages (array)
|
||||
App.controller('SystemMessagesController', ($http, $scope) => {
|
||||
$scope.messages = window.systemMessages
|
||||
$scope.messages = []
|
||||
var pollSystemMessages = function() {
|
||||
// Ignore polling if tab is hidden or browser is offline
|
||||
if (document.hidden || !navigator.onLine) {
|
||||
return
|
||||
}
|
||||
|
||||
$http
|
||||
.get('/system/messages')
|
||||
.then(response => {
|
||||
$scope.messages = response.data
|
||||
// Ignore if content-type is anything but JSON, prevents a bug where
|
||||
// the user logs out in another tab, then a 302 redirect was returned,
|
||||
// which is transparently resolved by the browser to the login (HTML)
|
||||
// page.
|
||||
// This then caused an Angular error where it was attempting to loop
|
||||
// through the HTML as a string
|
||||
if (response.headers('content-type').includes('json')) {
|
||||
$scope.messages = response.data
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// ignore errors
|
||||
|
|
Loading…
Reference in a new issue