mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
PHRAS-3442_optimize-list-notifications_4.1-bis
WIP fix : if user reconnects with another window/login, all windows will redirect to the home and log again
This commit is contained in:
@@ -10112,7 +10112,6 @@ var workzone = function workzone(services) {
|
||||
});
|
||||
|
||||
(0, _jquery2.default)('#idFrameC').on('click', '.basket_refresher', function () {
|
||||
console.log("======= CLINK ======");
|
||||
return workzoneOptions.refresh('current');
|
||||
});
|
||||
activeBaskets();
|
||||
|
@@ -10112,7 +10112,6 @@ var workzone = function workzone(services) {
|
||||
});
|
||||
|
||||
(0, _jquery2.default)('#idFrameC').on('click', '.basket_refresher', function () {
|
||||
console.log("======= CLINK ======");
|
||||
return workzoneOptions.refresh('current');
|
||||
});
|
||||
activeBaskets();
|
||||
|
@@ -89,6 +89,14 @@ class SessionManagerSubscriber implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_null($h_usr_id = $request->headers->get('user-id'))) {
|
||||
$a_usr_id = $this->app->getAuthenticator()->getUser()->getId();
|
||||
if((int)$h_usr_id !== (int)$a_usr_id) {
|
||||
$this->setDisconnectResponse($event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ANY route can disconnect the user if idle duration is passed
|
||||
//
|
||||
/** @var Session $session */
|
||||
|
@@ -117,10 +117,18 @@ var commonModule = (function ($, p4) {
|
||||
/**
|
||||
* pool notifications on route /user/notifications
|
||||
*
|
||||
* @param usr_id // the id of the user originally logged (immutable from twig)
|
||||
* @param update // bool to refresh the counter/dropdown
|
||||
* @param recurse // bool to re-run recursively (used by menubar)
|
||||
*/
|
||||
function pollNotifications(update, recurse) {
|
||||
function pollNotifications(usr_id, update, recurse) {
|
||||
var headers = {
|
||||
'update-session': recurse ? '0' : '1' // polling should not maintain the session alive
|
||||
// also : use lowercase as recomended / normalized
|
||||
};
|
||||
if(usr_id !== null) {
|
||||
headers['user-id'] = usr_id;
|
||||
}
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/user/notifications/",
|
||||
@@ -130,10 +138,7 @@ var commonModule = (function ($, p4) {
|
||||
'limit': 10,
|
||||
'what': 2, // 2 : only unread
|
||||
},
|
||||
headers: {
|
||||
'update-session': '0' // polling should not maintain the session alive
|
||||
// also : use lowercase as recomended / normalized
|
||||
},
|
||||
headers: headers,
|
||||
error: function (data) {
|
||||
if(data.getResponseHeader('x-phraseanet-end-session')) {
|
||||
self.location.replace(self.location.href); // refresh will redirect to login
|
||||
@@ -141,7 +146,7 @@ var commonModule = (function ($, p4) {
|
||||
},
|
||||
timeout: function () {
|
||||
if(recurse) {
|
||||
window.setTimeout(function() { pollNotifications(update, recurse); }, 10000);
|
||||
window.setTimeout(function() { pollNotifications(usr_id, update, recurse); }, 10000);
|
||||
}
|
||||
},
|
||||
success: function (data) {
|
||||
@@ -150,7 +155,7 @@ var commonModule = (function ($, p4) {
|
||||
updateNotifications(data);
|
||||
}
|
||||
if(recurse) {
|
||||
window.setTimeout(function() { pollNotifications(update, recurse); }, 30000);
|
||||
window.setTimeout(function() { pollNotifications(usr_id, update, recurse); }, 30000);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -171,7 +176,7 @@ var commonModule = (function ($, p4) {
|
||||
},
|
||||
success: function () {
|
||||
// update the counter & dropdown
|
||||
pollNotifications(true, false); // true:update ; false : do not recurse
|
||||
pollNotifications(null, true, false); // true:update ; false : do not recurse
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -417,9 +417,9 @@
|
||||
});
|
||||
|
||||
/**manage session and redirect to login page**/
|
||||
|
||||
var usr_id = '{{ app.getAuthenticator().user.getId }}';
|
||||
var module = '{{ module }}';
|
||||
|
||||
// start pooling recursively
|
||||
window.setTimeout( function() { commonModule.pollNotifications(module === 'prod', true); }, 2000);
|
||||
window.setTimeout( function() { commonModule.pollNotifications(usr_id, module === 'prod', true); }, 2000);
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user